0

I would like to insert a shortcode in the code just after "$cb_post_views" so the shortcode appears on the same line

if ( ( $cb_meta_onoff == 'on' ) || ( $cb_posts_on == true ) ) {
        $cb_byline = '<div class="cb-byline">' . $cb_author . $cb_date . $cb_cat_output . $cb_comments . $cb_post_views . '</div>';
    }

    return $cb_byline;
}}

I tried many things but I can't find a way out :(

Thanks for your help ;)

  • 1
    What have you tried? Can you show us? Whay do you want to insert a shortcode in a PHP script? In general, you can think in shortcodes as placeholders for PHP functions that output dinamic content to be used in contexts where PHP functions can not be used directly; within a PHP script there is no reason to use a placeholder, instead, you should use the shortcode's function callback directly (maybe tere are some situations where the callback can not be used directly, but I can not imaging one right now). – cybmeta Sep 11 '15 at 17:55
2

just use

<?php echo do_shortcode('[YOUR_SHORT_CODE_HERE]');?>

For more information:

Short-code in code file

$cb_byline = '<div class="cb-byline">' . $cb_author . $cb_date . $cb_cat_output . $cb_comments . $cb_post_views . do_shortcode('[YOUR_SHORT_CODE_HERE]'). '</div>';
}

For Plugin "I Recommend This" :

<?php if( function_exists('dot_irecommendthis') ) dot_irecommendthis(); ?>
  • Hi, Thanks for the fast response. I already tried that ;) and when I do it, the entire site disappear :( – saphiloche Sep 11 '15 at 16:32
  • 1
    What kind of short-code you are using, please share more details. – jas Sep 11 '15 at 16:35
  • If you are making custom theme please add this to functions.php as well: add_filter('the_content', 'do_shortcode', 11); – jas Sep 11 '15 at 16:36
  • 1
    please read this link for more information stackoverflow.com/questions/5282987/do-shortcode-not-working – jas Sep 11 '15 at 16:43
  • the shortcode is [dot_recommends] from that very simple plugin [link]wordpress.org/plugins/i-recommend-this/[/link]. The theme is a premium theme. 11 ? – saphiloche Sep 11 '15 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.