Site logo

Archived topic

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

9 replies · Started by Alessio Angeloro on April 6, 2018

Viewing posts 1–10 of 10

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,

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();

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

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;
}

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

Thanks! Working :-)

Awesome! No problem :)

This archived topic is closed to new replies.