Shortcodes in excerpt of custom post type
-
I’ve added a custom post type to the list of items to display in search results. The post_content of these posts has a shortcode encapsulating the content. I am trying to process the shortcode so that search results for this custom post type will display some content, but so far I’ve failed. What I have right now in my plugin file (simplied for relevant code) is:
final class darwin_core { private function setup() { add_action('init', array($this, 'dwc_add_shortcodes_to_excerpt' ) ); } function dwc_add_shortcodes_to_excerpt() { add_filter( 'get_the_excerpt', 'do_shortcode'); add_shortcode( 'dwc-post-content', array( $this, 'dwc_post_content_shortcode' ) ); } public function dwc_post_content_shortcode( $atts, $content = '', $tag = '' ) { return "testing"; } }
I am certain that setup() is being called.
Example post_content:
[dwc-post-content id="55575"]Chondrichthyes[/dwc-post-content]
I’ve tried a lot of variants of this configuration but nothing has worked. Do you have an idea of what I’m missing?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Shortcodes in excerpt of custom post type’ is closed to new replies.