1

I have a custom page template and in that template, I display the posts from the 3 custom post types

<?php
    $args = array('post_type' => 'news1','posts_per_page' => '10');
    $news = new WP_Query( $args );
    if ( $news->have_posts() ) :
        while ( $news->have_posts() ) : $news->the_post();?>
            <article id="post-<?php the_ID(); ?>" class="blog-post type3">
                <!-- **entry-meta - Starts** -->
                <div class="entry-meta">
                    <div class="date" style="padding:5px 10px;">
                        <p><span style="font-size:20px;"><?php the_time('d') ?></span><br><?php the_time('M') ?></p>
                    </div>
                    <div class="post-comments" style="padding:3px 10px;"></div>
                </div> <!-- **entry-meta - Ends** -->
                <div class="entry-detail">
                    <div class="entry-title">
                        <h4><a href="<?php get_the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    </div>
                    <div class="entry-body">
                    <?php
                        $trimmed = wp_trim_words( get_the_content(), $num_words = 55, $more = null );
                        $string = '<p>'.$trimmed.'</p>';
                        $string .= '<a href="'.get_the_permalink().'" class="dt-sc-button" style="font-size:11px;padding:5px 8px;">Read More</a>';

                        echo $string; ?>
                    </div>
                </div> <!-- **entry-detail - Ends** -->
         </article><!-- **Blog-post - Ends** -->
            <?php endwhile;
            else: ?>
            Ops! there's no news about corporate yet!
     <?php endif;
    wp_reset_query();
 ?>
<?php
    $args = array('post_type' => 'news2','posts_per_page' => '10');
    $news = new WP_Query( $args );
    if ( $news->have_posts() ) :
        while ( $news->have_posts() ) : $news->the_post();?>
            <article id="post-<?php the_ID(); ?>" class="blog-post type3">
                <!-- **entry-meta - Starts** -->
                <div class="entry-meta">
                    <div class="date" style="padding:5px 10px;">
                        <p><span style="font-size:20px;"><?php the_time('d') ?></span><br><?php the_time('M') ?></p>
                    </div>
                    <div class="post-comments" style="padding:3px 10px;"></div>
                </div> <!-- **entry-meta - Ends** -->
                <div class="entry-detail">
                    <div class="entry-title">
                        <h4><a href="<?php get_the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    </div>
                    <div class="entry-body">
                    <?php
                        $trimmed = wp_trim_words( get_the_content(), $num_words = 55, $more = null );
                        $string = '<p>'.$trimmed.'</p>';
                        $string .= '<a href="'.get_the_permalink().'" class="dt-sc-button" style="font-size:11px;padding:5px 8px;">Read More</a>';

                        echo $string; ?>
                    </div>
                </div> <!-- **entry-detail - Ends** -->
         </article><!-- **Blog-post - Ends** -->
            <?php endwhile;
            else: ?>
            Ops! there's no news about corporate yet!
     <?php endif;
    wp_reset_query();
 ?>
<?php
    $args = array('post_type' => 'news3','posts_per_page' => '10');
    $news = new WP_Query( $args );
    if ( $news->have_posts() ) :
        while ( $news->have_posts() ) : $news->the_post();?>
            <article id="post-<?php the_ID(); ?>" class="blog-post type3">
                <!-- **entry-meta - Starts** -->
                <div class="entry-meta">
                    <div class="date" style="padding:5px 10px;">
                        <p><span style="font-size:20px;"><?php the_time('d') ?></span><br><?php the_time('M') ?></p>
                    </div>
                    <div class="post-comments" style="padding:3px 10px;"></div>
                </div> <!-- **entry-meta - Ends** -->
                <div class="entry-detail">
                    <div class="entry-title">
                        <h4><a href="<?php get_the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    </div>
                    <div class="entry-body">
                    <?php
                        $trimmed = wp_trim_words( get_the_content(), $num_words = 55, $more = null );
                        $string = '<p>'.$trimmed.'</p>';
                        $string .= '<a href="'.get_the_permalink().'" class="dt-sc-button" style="font-size:11px;padding:5px 8px;">Read More</a>';

                        echo $string; ?>
                    </div>
                </div> <!-- **entry-detail - Ends** -->
         </article><!-- **Blog-post - Ends** -->
            <?php endwhile;
            else: ?>
            Ops! there's no news about corporate yet!
     <?php endif;
    wp_reset_query();
 ?>

and now, I want to display the archives of each custom post type e.g. display the archives list of the custom post type name "new1" and so to the other custom post types, is it possible to display the archives of each custom post types? any ideas, help please?

  • what do you mean archives? archives of custom post type contain post that listed in your code. – Jevuska Apr 6 '16 at 16:20
  • Perhaps you don't quite get it, to sharpen the details, I just want to display the custom post type archives (listed per year, months like you see in any regular sidebar) but this is different where what I want is to list 3 different custom post type archives in a single page. Any ideas? – Juliver Galleto Apr 7 '16 at 1:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.