Custom shortcode skips every 2nd shortcode

Question

I’m have the oddest problem.

I have a shortcode that querys the DB and returns the result based on the attribute text. The shortcode worked perfectly when I tested using just 1 version. I then used the shortcode multiple times on the same page and it suddenly skips every 2nd shortcode. What could be going on here? I don’t see anything in developer console on Chrome too.

    //Global Company Info Shortcode
add_shortcode('company_info', 'get_company');

function get_company( $atts, $content ) {
    $a = shortcode_atts(
    array(
    'col' => ''
    ), $atts, 'company_info');
    
    global $wpdb;
    global $current_user;
    $current_user = get_current_user_id(); 
    
    $results = $wpdb->get_row($wpdb->prepare("SELECT ".$a['col']." FROM p_company WHERE user_id = %s",$current_user), ARRAY_A);
    return $results[$a['col']];
    
};

Shortcodes in use

enter image description here

0
stevep1986 2 weeks 2022-08-03T06:26:14-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse