Site logo

[Support request] Custom post type on archive pages with GeneratePress

Home Forums Support [Support request] Custom post type on archive pages with GeneratePress

Home Forums Support Custom post type on archive pages with GeneratePress

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2594300
    David

    Hey guys,

    I’m adding a custom post type to the archive pages with:

    public function add_products_to_archives( $query ) {
      if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', array(
          'post', 'gp_elements', 'nav_menu_item', 'products'
        ));
      return $query;
      }
    }

    This works, but removes the wrapper and classes that GeneratePress otherwise adds around and to the articles.

    This is your usual code:

    <main class="site-main" id="main">
      <div class="generate-columns-container ">
        <header class="page-header" aria-label="Page"> ... </header>
    	<article id="post-9505" class="post-9505 post type-post status-publish format-standard has-post-thumbnail hentry category-gear generate-columns tablet-grid-50 mobile-grid-100 grid-parent grid-33 resize-featured-image"> ... </article>
    	<article ...
    </div><!-- .generate-columns-contaier -->
    </main>

    It becomes:

    <main class="site-main" id="main">
      <header class="page-header" aria-label="Page"> ... </header>
      <article id="post-10154" class="post-10154 products type-products status-publish hentry category-inflatable product_tag-inflatable">...</article>
      <article ...
    </main>

    The wrapper div and extra classes are gone.

    Can you help me out?

    Thanks,
    David

    #2594420
    David
    Staff
    Customer Support

    Hi there,

    columns have to be applied to the custom post types too – see here:

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

    #2594525
    David

    Thanks David, that works!

    #2595914
    David
    Staff
    Customer Support

    Glad to hear that

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