Site logo

Archived topic

How to include pages in archives?

3 replies · Started by Espen on October 27, 2022

Viewing posts 1–4 of 4

Hi,

I have some pages that I have given tags. I want them to be included as part of the grid in the tags archives.

I found this code online

 // ensure all pages are included in tag queries
function tags_support_query($wp_query) {
	if ($wp_query->get('tag')) $wp_query->set('post_type', 'any');
}
add_action('pre_get_posts', 'tags_support_query');

It kind of works, but they are not given the Generatepress classes

generate-columns tablet-grid-50 mobile-grid-100 grid-parent grid-33

So it breaks the grid and styling.

Any way I can make them get the classes?

Thank you!

-Espen

Hi Espen,

Try adding this PHP snippet:

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

    return $columns;
} );

Thank you, Fernando. That worked perfectly!

-Espen

You're welcome Espen!

This archived topic is closed to new replies.