Group Admins

  • Profile picture of Steve

WordPress Troubleshooting and Support

Public Group active 6 months, 2 weeks ago ago

WordPress support from our community

Custom Post Types and Shortcodes

This topic contains 0 replies, has 2 voices, and was last updated by  Chad 8 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1170

    Chad
    Participant

    Hello everyone,

    I am running into a problem with Custom Post Types and Shortcodes.
    The problem is that shortcodes will not show up when i use them in a CPT. Why?

    I found some thing about adding add_filters(); on the codex but it seems that it not working.

    Can someone give me another direction or point me to a place that may have a solution.

    Thanks
    Chad

    #1906

    Steve
    Keymaster

    I don’t think there’s anything special about custom post types and shortcodes. I just did a quick test with the following code and it worked fine on one of the videos on this site, which is a CPT:

    function sfire_shortcode_example() {
    return ‘This is a sample of a shortcode.‘;
    }
    add_shortcode(‘sampleshortcode’, ‘sfire_shortcode_example’);

    Here are the args for the post type, which may help you:

    $args = array(
    ‘labels’ => $labels,
    ‘public’ => true,
    ‘publicly_queryable’ => true,
    ‘show_ui’ => true,
    ‘show_in_menu’ => true,
    ‘query_var’ => true,
    ‘rewrite’ => true,
    ‘capability_type’ => ‘post’,
    ‘has_archive’ => true,
    ‘hierarchical’ => false,
    ‘menu_position’ => 5,
    ‘supports’ => array(‘title’,’editor’,’custom-fields’,’revisions’,’comments’),
    ‘taxonomies’ => array(‘category’,’post_tag’)
    );

    #1907

    Chad
    Participant

    Steve,

    Thanks for the response. I realized that i was using the_excerpt(); instead of the_content(); to output the info and of course that would not work.

    Thanks for your time
    Chad

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.