Site logo

Archived topic

Custom Post Types Remove the Column Layout for Assigned Category Page

6 replies · Started by Ken on July 15, 2021

Viewing posts 1–7 of 7

Hi,
First, thank you again for the help with getting Custom Posts to show up. Much appreciated.

My coach got back to me with the following:

When I assign a custom post type to a category it removes the column layout for that category page. I followed the steps in this post to add columns code to the child theme’s functions.php file but it doesn’t seem to work:  https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type.  Maybe the code is supposed to be inside the custom post template instead? Can you check with support?

Can you help me with this? I'll need a screenshot of where this code will need to go.

Note I'm assuming she used this code found in the above link:

add_filter( 'generate_blog_columns','tu_portfolio_columns' );
function tu_portfolio_columns( $columns ) {
    if ( is_post_type_archive( 'portfolio' ) ) {
        return true;
    }

    return $columns;
}

Hi Ying,
Thank you for getting back to me. Deepest apologies, I'm a super newbie with this. I see Portfiolo, thank you for the screenshot.

My problem: I'm not sure what to copy-n-paste and how to copy-n-paste for the 'five' custom post types.
here's what my coach set up:
single-five_product.php
content-five_product.php

single-how_to.php
content-how_to.php
single-list_post.php
content-list_post.php
single-one_product.php
content-one_product.php
single-ten_product.php
content-ten_product.php

I believe I only need to work with the 'single.." code. I don't need to work with the "content.." code.
But I don't know exactly how to add the five ("single...") custom post codes.
Can you give me an example?
Again, appreciate your patience, understanding, and help.

Ooops, didn't include in B-Quote:

single-five_product.php
content-five_product.php

If you want to apply this filter to sepecific post types, then try this one:

add_filter( 'generate_blog_columns','tu_portfolio_columns' );
function tu_portfolio_columns( $columns ) {
    if ( is_post_type_archive( array('post-type-1', 'post-type-2' ))  {
        return true;
    }
    return $columns;
}

Replace the post-type-1, post-type-2with your own custom post type names.

You can find the custom post type in the CPT UI:
https://www.screencast.com/t/kLWtwAe3F7

Let me know if this helps :)

Hi Ying!
Woo !Hoo! Problem solved! Thank you. You provided the right example that helped me solve the problem.
Custom Posts show up under Categories looking good!
Thank you for your help.
As always GP-Support is amazing!
I'll close this ticket with a smile, hoping you have a smile too. \(*<>*)/

You are very welcome Ken, here's my big smile :) haha

I'm glad to be helpful!

This archived topic is closed to new replies.