Answer the question
In order to leave comments, you need to log in
How to display article announcements on a separate Wordpress page?
Hello dear community members. Can you please tell me how to display the announcements of articles on a separately created page?
I created a new template for the page by copying the code from page.php
This is how the code looked 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() )
comments_template();
?>
<?php endwhile; ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<?php query_posts('category_name=camps'); while ( have_posts() ) : the_post(); ?>
Answer the question
In order to leave comments, you need to log in
I would just replace your loop with something like this
<?php
if ( have_posts() ){
query_posts('category_name=camps');
while ( have_posts() ){
the_post();
echo '<div class="post-item"><p><span class="post-title">' . get_the_title() . '</span></p>'; // Название статьи
echo '<p class="post-min_content">' .get_the_excerpt(). '</p>'; // миниатюра статьи (то что вам нужно)
echo '<div class="open-post"><a href="'. get_permalink() .'" class="link-post">Читать</a></div></div>'; // Ссылка на полную версию поста
}
}
else{
echo ' <p>Записей нет...</p>';
}
?>
Hello.
Google will not help here) See the template for your topic. Most likely, entries with announcements are displayed in archives or categories. Accordingly, look for archive.php category.php taxonomy.php Here you can find the method they use to output excerpts. And so the standard method
<? php the_excerpt (
)
?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question