• Resolved teracomp

    (@teracomp)


    I’m using download-monitor and yet-another-star-rating plugin.

    For every download (post_type==’dlm_download’), there is a custom field labeled short_description which happens to be the post_excerpt.

    I want to add the shortcode [yasr_visitor_votes size=”medium”] to every download to allow visitors to vote on the download.

    Something like

    function add_visitor_vote( $content ) {
      global $post;
      if ( $post->post_type == 'dlm_download' ) {
    	  $my_excerpt = $post->post_excerpt;
    	  $my_excerpt .= '[yasr_visitor_votes size="medium"]';
    	  $content .= $my_excerpt;
      }
      return $content;
    }
    
    add_filter( 'the_excerpt', 'add_visitor_vote' );

    Shouldn’t it be that simple??

Viewing 1 replies (of 1 total)
  • Thread Starter teracomp

    (@teracomp)

    This works:

    function add_visitor_vote( $content ) {
      global $post;
      if ( $post->post_type == 'dlm_download' ) {
        $content .= do_shortcode('[valid_shortcode]');
      }
      return $content;
    }
    add_filter( 'the_content', 'add_visitor_vote' );

    But it doesn’t work with the shortcode I’m currently trying to use. Posted comment on that site.

Viewing 1 replies (of 1 total)
  • The topic ‘Add shortcode to custom post type excerpt’ is closed to new replies.