[Resolved] Which the correct file to create cpt loop in 3 columns layout ?

Home Forums Support [Resolved] Which the correct file to create cpt loop in 3 columns layout ?

Home Forums Support Which the correct file to create cpt loop in 3 columns layout ?

  • This topic has 9 replies, 3 voices, and was last updated 6 years ago by Tom.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #542788
    Alessio Angeloro

    Hi Tom,

    i create some custom post type with custom taxonomy, now i need to view it at front end by using “customizer” -> 3 coluns layout, but may be i’m wrong something, which the correct file that i must duplicate in my template child to loop my custom post type ? because the customizer wont works on my my custom template cpt.

    Regards,

    #543035
    Leo
    Staff
    Customer Support
    #543167
    Alessio Angeloro

    Hi Leo,

    i apologize but not working.

    This is my code : archive-annunci.php

    <?php
    /**
     * The template for displaying Archive pages.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package GeneratePress
     */
    
    get_header(); ?>
    
    <?php
    
    $cpt_query = new WP_Query(array(
    'post_type'			=> 'annunci',
    'taxonomy'			=> 'categoria_annunci',
    'posts_per_page'	=> 25,
    'orderby'			=> 'none',
    'order'				=> 'DESC'
    ));
    
    ?>
    
    	<div id="primary" <?php generate_content_class();?>>
    		<main id="main" <?php generate_main_class(); ?>>
    			<?php
    			/**
    			 * generate_before_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_before_main_content' ); ?>
    
    			<?php if( $cpt_query->have_posts() ): ?>
    
    			<?php while( $cpt_query->have_posts() ) : $cpt_query->the_post(); ?>
    
    			<?php get_template_part( 'content', 'page' );
    			
    			 echo get_the_term_list( $post->ID, 'categoria_annunci', '', ', ' );
    
    				// If comments are open or we have at least one comment, load up the comment template.
    				if ( comments_open() || '0' != get_comments_number() ) : ?>
    
    					<div class="comments-area">
    						<?php comments_template(); ?>
    					</div>
    
    				<?php endif;
    
    			endwhile;
    
    			/**
    			 * generate_after_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_after_main_content' );
    			?>
                
    		</main><!-- #main -->
    	</div><!-- #primary -->
        
         <?php //endwhile; ?>
    	 <?php endif; ?>
    
    	<?php
    	/**
    	 * generate_after_primary_content_area hook.
    	 *
    	 * @since 2.0
    	 */
    	 do_action( 'generate_after_primary_content_area' );
    
    	 generate_construct_sidebars(); 
    
    do_action('generate_sidebars');
    get_footer();
    #543493
    Tom
    Lead Developer
    Lead Developer

    Any chance you can link me to one of those CPT pages?

    #543590
    Alessio Angeloro
    #543941
    Tom
    Lead Developer
    Lead Developer

    And you’ve added the code Leo linked to, along with your post type name?: https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type

    #544748
    Alessio Angeloro

    Yes, i have tried this

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

    and this

    add_filter( 'generate_blog_masonry','tu_portfolio_masonry' );
    function tu_portfolio_masonry( $masonry ) {
        if ( is_post_type_archive( 'annunci' ) ) {
            return 'true';
        }
    
        return $masonry;
    }
    #544884
    Tom
    Lead Developer
    Lead Developer

    Maybe instead of is_post_type_archive(), try: is_tax( 'categoria_annunci' )

    #545031
    Alessio Angeloro

    Thanks! Working ๐Ÿ™‚

    #545363
    Tom
    Lead Developer
    Lead Developer

    Awesome! No problem ๐Ÿ™‚

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