• Caen

    (@caen)


    Hello fellow wordpress expirienced users.
    Iā€™m having a struggle while doing a latest 3 posts excerpt with thumbnail in my homepage.
    I tried various possibilities but i cant get it running.
    The goal is to look the posts like this:
    https://caenthemes.cekuj.net/?s=p%C5%99%C3%ADsp%C4%9Bvek
    but i was only able to go here: https://caenthemes.cekuj.net/
    The code of the main page:

    <?php
    /**
     * The template for displaying main-page without title.
     * @package WordPress
     * @subpackage Twenty_Sixteen
     * @since Twenty Sixteen 1.0
     */
    ?>
    
    <section id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <!--<header class="entry-header">
        <?php the_title('<h1 class="entry-title">', '</h1>'); ?>
        </header><!-- .entry-header -->
        <div class="wp-page-content">
            <?php
            the_content();
            wp_link_pages(array(
                'before' => '<div class="page-links"><span class="page-links-title">' . __('Pages:', 'twentysixteen') . '</span>',
                'after' => '</div>',
                'link_before' => '<span>',
                'link_after' => '</span>',
                'pagelink' => '<span class="screen-reader-text">' . __('Page', 'twentysixteen') . ' </span>%',
                'separator' => '<span class="screen-reader-text">, </span>',
            ));
            ?>
        </div><!-- .entry-content -->
    </section>   
    <section>
        <header class="entry-header">
            <h2>
                <?php
                if (get_locale() == 'cs_CZ') {
                    echo "Nejnověj?ƭ p?ƭspěvky";
                } else {
                    echo "Latest posts";
                }
                ?>
            </h2>
        </header><!-- .entry-header -->
    
        <?php
        $args = array(
            'posts_per_page' => 3,
            'offset' => 0,
            'category' => '',
            'category_name' => '',
            'orderby' => 'date',
            'order' => 'DESC',
            'include' => '',
            'exclude' => '',
            'meta_key' => '',
            'meta_value' => '',
            'post_type' => 'post',
            'post_mime_type' => '',
            'post_parent' => '',
            'author' => '',
            'author_name' => '',
            'post_status' => 'publish',
            'suppress_filters' => true
        );
        $myposts = get_posts($args);
        foreach ($myposts as $post) : setup_postdata($post);
            get_template_part('template-parts/content', 'search');
        endforeach;
        wp_reset_postdata();
        ?>
    </section><!-- #wp-page-content-## -->

    Iā€™m 80% sure that iā€™m not handling right the inner loop within the main loop of twenty sixteen. Just to cover all posibilities i was also trying to do it not via get template but still i only get the posts categories titles and thumbnails but not the excerpt.
    Can you help me with this ?
    The whole page is based on twenty sixteen theme with my modifications.
    Thank you very much,
    Caen Ragestorm

  • The topic ‘etting excerpt in loop within loop ā€“ Twenty sixteen theme’ is closed to new replies.