- This topic has 5 replies, 4 voices, and was last updated 7 years, 2 months ago by Tom.
-
AuthorPosts
-
December 13, 2016 at 1:13 am #254165Patrick
Hi Tom,
how is it possible to use the bloglayout (the archiv/overview page, not the detailpage) for a custom posttype to? I like the same design for my custom posttye as for the blog.
thanks and regards
patrickDecember 13, 2016 at 2:11 am #254178PatrickAdditonal, like to have it as masonry styled boxes
December 13, 2016 at 10:35 am #254348LeoStaffCustomer SupportHi Patrick,
I would suggest checking out Tom’s WP Show Post plugin for any blog customization.
https://en-ca.wordpress.org/plugins/wp-show-posts/
Hope this helps!December 13, 2016 at 11:42 am #254370TomLead DeveloperLead DeveloperThere’s a handy filter you can use to apply masonry to your custom post types:
add_filter( 'generate_blog_masonry','generate_adjust_masonry' ); function generate_adjust_masonry( $masonry ) { if ( is_post_type_archive( 'portfolio' ) ) : return 'true'; endif; if ( is_post_type_archive( 'news' ) ) : return 'true'; endif; if ( is_post_type_archive( 'events' ) ) : return 'true'; endif; return $masonry; }
Same with columns:
add_filter( 'generate_blog_columns','generate_adjust_columns' ); function generate_adjust_columns( $columns ) { if ( is_post_type_archive( 'portfolio' ) ) : return true; endif; return $columns; }
January 20, 2017 at 4:19 am #266130DanielI have tried to get this to work, but it does not seem to work with my custom post type page template.
My custom template works, but I know I am doing it the wrong way to get it to work with masonry.
I guess I need to copy the index and content page and then put my custom loop in the content page, is that correct?Here is my custom template code as it stands.
<?php
/**
* Template Name: Case Studies
*/get_header(); ?>
<section class=”page-padding”>>
<main id=”main” <?php generate_main_class(); ?>>
<h1>Case Studies</h1>
<?php do_action(‘generate_before_main_content’); ?>
<?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; ?>
<?php // WP_Query arguments
$args = array(
‘post_type’ => array( ‘casestudies’ ),
‘post_status’ => array( ‘publish’ ),
‘posts_per_page’ => ’10’,
‘order’ => ‘DESC’,
‘orderby’ => ‘date’,
‘paged’ => $paged,
); query_posts($args);// The Query
$cases = new WP_Query( $args ); ?>
<?php if ( $cases->have_posts() ) : ?>
<?php while ( $cases->have_posts() ) : $cases->the_post(); ?><?php the_post_thumbnail(‘medium’); ?><?php endwhile; ?>
<!– Add the pagination functions here. –><?php next_posts_link( ‘Older posts’ ); ?><?php previous_posts_link( ‘Newer posts’ ); ?><?php endif; ?>
<?php wp_reset_query(); ?>
<?php do_action(‘generate_after_main_content’); ?>
</main><!– #main –><!– #primary –>
<?php
do_action(‘generate_sidebars’);?>
</section>
<?php get_footer();January 20, 2017 at 9:59 am #266225TomLead DeveloperLead DeveloperAs long as the template has all the proper hooks etc.. You should be able to enable masonry on it using a function like the one on this page: https://docs.generatepress.com/article/using-columns-in-the-blog
-
AuthorPosts
- You must be logged in to reply to this topic.