[Support request] Blog design for custom posttype

Home Forums Support [Support request] Blog design for custom posttype

Home Forums Support Blog design for custom posttype

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #254165
    Patrick

    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
    patrick

    #254178
    Patrick

    Additonal, like to have it as masonry styled boxes

    #254348
    Leo
    Staff
    Customer Support

    Hi 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!

    #254370
    Tom
    Lead Developer
    Lead Developer

    There’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;
    }
    #266130
    Daniel

    I 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’); ?>
    <h2><?php the_title(); ?></h2>
    <?php
    echo wp_trim_words( get_the_content(), 60, ‘… Read More‘ );
    ?>

    <?php endwhile; ?>
    <!– Add the pagination functions here. –>

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

    #266225
    Tom
    Lead Developer
    Lead Developer

    As 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

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