I've a custom post type " Calendarize it ". And i would like to show at the end of the exerpt the custom taxonomy "Price". The price can be display by using this shortcode :

[rhc_term taxonomy="prix"]

I use this code :

add_filter( 'get_the_excerpt', 'shortcodetext_in_excerpt' );
function shortcodetext_in_excerpt( $excerpt ) {
    $more = ' <a href="'. get_permalink( get_the_ID() ) . '">Lire la suite</a>';
    $content = wp_trim_words( get_the_content(), 35, $more );
    return preg_replace( '/\[[^\]]+\]/', '', $content );

And it works well. But how can i insert my shortcode. Who can help me.

Thanks a lot

  • Use this plugin: Insert PHP Code Snippet. It converts PHP snippets to shortcodes. – Prakash Pazhanisamy Sep 11 '17 at 11:05
  • Where do you want to insert the shortcode? in the excerpt? You want to append the shorcode to the excerpt? Can you be please a bit more descriptive. – Annapurna Sep 11 '17 at 12:14
  • Yes.I use a custom post type. It allows me to create events that have attributes such as place, time of the event, and price. I use another plugin to display these events. This plugin takes the excerpt of wordpress. I would like to custom it to have: Excerpt - Event price- Read more. Can i insert the shortcode in the excerpt ? – Claudia Sep 11 '17 at 21:20

Your Answer

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

Browse other questions tagged or ask your own question.