[Resolved] Adding columns to your custom post type

Home Forums Support [Resolved] Adding columns to your custom post type

Home Forums Support Adding columns to your custom post type

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #2162766
    Quested

    Hi
    I want to add columns to my custom post type. I tried many times but its not working. Custom Post Type archive name is Projects.

    I already gone through this article. https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type

    Kindly help.

    Humble Regards
    Quested

    #2162778
    Ying
    Staff
    Customer Support

    Hi there,

    Try this PHP snippet:

    add_filter( 'generate_blog_columns', function( $columns ) {
        if ( 'projects' === get_post_type() && ! is_singular() ) {
            return true;
        }
    
        return $columns;
    } );

    Make sure you’ve set the column setting at customizer > layout > blog.

    #2162965
    Quested

    Awesome.
    Worked perfectly.
    Thank you so much for the help.

    #2163714
    Ying
    Staff
    Customer Support

    You are welcome 🙂

    #2261035
    Quested

    Hi
    I am redesigning another website from Divi to GeneratePress. I want to add columns to my custom post type. I tried many times but its not working. Custom Post Type archive name is Reviews.

    #2261072
    David
    Staff
    Customer Support

    Hi there,

    can you share the exact code you added ?

    #2261121
    Quested

    I have given you temporary access to my site.

    #2261153
    David
    Staff
    Customer Support

    Where did you add the PHP Snippet ? I don’t see it on your site

    #2261164
    Quested

    You can check the Theme Editor.
    I added the code again.

    You can add or edit the code. You have full control.

    #2261169
    David
    Staff
    Customer Support

    Ok check now.

    I changed the post type slug to review

    #2261207
    Quested

    Thank you so much for your help.

    #2261471
    David
    Staff
    Customer Support

    You’re welcome!

    #2263174
    Quested

    I want to add same 3 columns to my another custom post type. Custom Post Type archive name is Buyer Guides.
    I have given you full access to check the code in Theme Editor. You can make the changes required.

    #2263188
    David
    Staff
    Customer Support

    Change this code:

    add_filter( 'generate_blog_columns', function( $columns ) {
        if ( 'review' === get_post_type() && ! is_singular() ) {
            return true;
        }
    
        return $columns;
    } );

    to this code:

    add_filter( 'generate_blog_columns', function( $columns ) {
        if ( ( 'review' === get_post_type() || 'buyer-guides' === get_post_type() ) && ! is_singular() ) {
            return true;
        }
    
        return $columns;
    } );
    #2263190
    Quested

    You guys are awesome.
    Thank you so much for quick help.

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.