Manual excerpt being ignored on custom post type

I've set up some custom post types with Pods, but can't seem to get it to display my manual excerpt. It's working fine for my normal posts.

I've tried displaying it with echo get_the_excerpt() and the_excerpt(). I've tried doing it using get_posts() and setup_postdata(). I've also tried a standard WP_Query loop.

No matter what I do, it just gives me the automatically generated excerpt.

Any ideas?

        ?php
        $posts = get_posts(array(
            'post_type' = 'press-release'
        ));
        foreach ($posts as $i = $post) { 
            setup_postdata($post); ?
            div class="row press appear" on-visible="{class: 'visible'}"
                div class="columns small-3"
                    p class="date"?php echo get_the_date('M j Y'); ?/p
                /div
                div class="columns small-9"
                    h2a target="_blank" href="?php echo get_the_permalink(); ?"?php the_title(); ? nbsp; /a/h2
                    div class="excerpt"?php the_excerpt(); ?/div
                /div
            /div
        ?php 
        } ?

Topic pods-framework excerpt Wordpress

Category Web


When you use the register_post_type function you will need to include support for excerpts:

add_action( 'init', 'press_release_post_type' );
function press_release_post_type() {

    register_post_type( 'press_release',
        array(
            'labels' => array(
                'name'          => __( 'Press Release', '$text_domain' ),
                'singular_name' => __( 'Press Release', '$text_domain' ),
            ),
            'has_archive'  => true,
            'hierarchical' => true,
            'public'       => true,
            'rewrite'      => array( 'slug' => 'press_release', 'with_front' => false ),
            'supports'     => array( 'title', 'excerpt' ),

        )
    );
    
}

supports

An alias for calling add_post_type_support() directly.


Ok I figured it out. My custom post type was called press_release not press-release, and instead of returning no results, wordpress was returning some arbitrary collection of results that were broken in weird ways.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.