How to display previews of articles on a separate Wordpress page?

Hello, dear community members. Tell me, please, how to get announcements of articles on a separately created page?
I created a new template page by copying the code from page.php

So the code looks like originally:
<?php get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>

<?php if ( comments_open() || '0' != get_comments_number() )

<?php endwhile; ?>


<?php get_sidebar(); ?>
<?php get_footer(); ?>

I added the function query_posts('category_name=camps'); before the while loop. I made this design:
<?php query_posts('category_name=camps'); while ( have_posts() ) : the_post(); ?>

In my case, the "camps" is the slug column.
Everything works, but the articles are displayed in expanded form (as a whole), and I need to look in the announcements when filtering by category. Google all day, but never managed to find anything intelligible

Thank you in advance for your answers.
June 7th 19 at 15:43
3 answers
June 7th 19 at 15:45
I would have just replaced your cycle is something like this
 if ( have_posts() ){
 while ( have_posts() ){
 echo '<div class="post-item"--><p><span class="post-title">' . get_the_title() . '</span></p>'; // article Title

 echo '<p class="post-min_content">' .get_the_excerpt(). '</p>'; // thumbnail of the article (what you need)

 echo '<div class="open-post"><a href="'. get_permalink() .'" class="link-post">Read</a></div>'; // Link to the full post
 echo ' <p>no Records.</p>';

just a piece of blog post which I have made , so that html markup its substitute .
Thanks, that's better. But for some reason, are these announcements a little differently now. The standard design of the theme is not applied..

Here's how:5a918bab7faa1700663185.jpeg

But how is it Your method:5a918bd96e84c720400571.jpeg - verona_Hartma commented on June 7th 19 at 15:48
Well look at the code of your theme (where Inyodada thumbnails) as they are displayed and replace the function get_the_excerpt() on a method from their code . - raheem.Homenic commented on June 7th 19 at 15:51
or here - raheem.Homenic commented on June 7th 19 at 15:54
I can't do that, as not a die in php and unable to understand intuitively what functions are performed, when I filter the posts by category. The theme contains many files, the purpose of which I represent very vaguely. If these withdrawal methods are unique to each individual topic, the question can be considered closed - verona_Hartma commented on June 7th 19 at 15:57
June 7th 19 at 15:47
Google will not help here) See the pattern of your theme. Most likely, record the announcements appear in archives or categories. Accordingly, the search for archive.php category.php taxonomy.php Here you can find a method that they use to display excerpts. And so the standard method

And all the other details you Konstantin already wrote, even painted))
Also on the page via page.php recording can be fed through WP_Query
Hello. I hope I don't banned for similar issues) If You don't mind, can You detect in this code, the desired function? This content archive.php by the Way, by default wordpress does not allow you to archive recordings, so I can't see how he represents them. I would have written to You in a PM or mail, but the functionality of the toaster does not allow it.


get_header(); ?>

 <section id="primary" class="content-area">
 <div id="content" class="site-content" role="main">

 <?php if ( have_posts() ) : ?>

 <header class="page-header">
 <h1 class="page-title">
 if ( is_category() ) :

 elseif ( is_tag() ) :

 elseif ( is_author() ) :
 /* Queue the first post, that way we know
 * what author we're dealing with (if that is the case).
 printf( __( 'Author: %s', 'hiero' ), '<span class="vcard"--><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" title="' . esc_attr( get_the_author() ) . '" rel="me">' . get_the_author() . '</a>' );
 /* Since we called the_post() above, we need to
 * rewind the loop back to the beginning that way
 * we can run the loop properly, in full.

 elseif ( is_day() ) :
 printf( __( 'Day: %s', 'hiero' ), '<span>' . get_the_date() . '</span>' );

 elseif ( is_month() ) :
 printf( __( 'Month: %s', 'hiero' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );

 elseif ( is_year() ) :
 printf( __( 'Year: %s', 'hiero' ), '<span>' . get_the_date( 'Y' ) . '</span>' );

 elseif ( is_tax( 'post_format', 'post-format-aside' ) ) :
 _e( 'Asides', 'hiero' );

 elseif ( is_tax( 'post_format', 'post-format-image' ) ) :
 _e( 'Images', 'hiero');

 elseif ( is_tax( 'post_format', 'post-format-video' ) ) :
 _e( 'Videos', 'hiero' );

 elseif ( is_tax( 'post_format', 'post-format-quote' ) ) :
 _e( 'Quotes', 'hiero' );

 elseif ( is_tax( 'post_format', 'post-format-link' ) ) :
 _e( 'Links', 'hiero' );

 else :
 _e( 'Archives', 'hiero' );

 // Show an optional term description.
 $term_description = term_description();
 if ( ! empty( $term_description ) ) :
 printf( '<div class="taxonomy-description"-->%s</header></div>', $term_description );
 <!-- .page-header -->

 <?php /* Start the Loop */ ?>
 <?php while ( have_posts() ) : the_post(); ?>

 /* Include the Post Format-specific template for the content.
 * If you want to overload this in a child theme then include a file
 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
 get_template_part( 'content', get_post_format() );

 <?php endwhile; ?>

 <?php athemes_content_nav( 'nav-below' ); ?>

 <?php else : ?>

 <?php get_template_part( 'no-results', 'archive' ); ?>

 <?php endif; ?>

 <!-- #content -->
 <!-- #primary --></section>

<?php get_sidebar(); ?>
<?php get_footer(); ?>
- verona_Hartma commented on June 7th 19 at 15:50
June 7th 19 at 15:49
Thank you comrades Konstantin Teploukhov and azerphoenix. Through their responses the required functionality was independently found. This is get_template_part( 'content', 'search' ); in search.php
get_template_part( 'content', 'search' );

suggests that he should get a template with the name content-search.php or search.php
But what it contains is necessary to look. Most likely there's also displays a cycle.
Glad the situation is cleared up. - verona_Hartma commented on June 7th 19 at 15:52

Find more questions by tags WordPress