[Resolved] How to include pages in archives?

Home Forums Support [Resolved] How to include pages in archives?

Home Forums Support How to include pages in archives?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2390550
    Espen

    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

    #2390615
    Fernando
    Customer Support

    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;
    } );
    #2391110
    Espen

    Thank you, Fernando. That worked perfectly!

    -Espen

    #2397472
    Fernando
    Customer Support

    You’re welcome Espen!

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