Shortcode will not process using do_shortcode
-
I find that the content_block shortcode will not process (i.e., the shortcode code displays, not the return of the shortcode) in some situations when custom shortcodes I’ve created DO process.
For example, I created a Custom Post Type for which I want the Description (which appears at the top of the CPT archive page) to be created/edited by my client. So, instead of hardcoding the Description inside the function that registers the CPT, I created a Content Block to store the CPT description. I added placeholder content.
I have a function that returns the description, which originally was this…
function seba_directors_blurb() { $output = '<p>This is a description of this CPT.</p>'; return $output; }
In the CPT registration function, I have this line…
$args = array( 'label' => __( 'SEBA Director', 'text_domain' ), 'description' => seba_directors_blurb(), {etc.}
Then, after adding the Content Block for the CPT description, I altered the first function to be this…
function seba_directors_blurb() { $output = do_shortcode('[content_block id=1118]'); return $output; }
The result is that this appears on the front end:
[content_block id=1118]
However, when I created a simple custom shortcode that returns placeholder text, it works.
I hope this makes sense. Any thoughts?
- The topic ‘Shortcode will not process using do_shortcode’ is closed to new replies.