Answer the question
In order to leave comments, you need to log in
Showing a page and a post in a Wordpress category?
Good afternoon!
Tell me how you can display the post page in the Wordpress heading:
I explain the page (page.php), heading (archive.php), posts (single.php). A small nuance of the entry must be of a certain category.
Tried with :
<?php
if ( have_posts() ) : // если имеются записи в блоге.
query_posts( array( 'taxonomies' => 'remont-kompyuterov-v-kazani' ) ); // указываем ID рубрик, которые необходимо вывести.
while (have_posts()) : the_post(); // запускаем цикл обхода материалов блога
get_template_part( 'content', get_post_format() );
endwhile; // завершаем цикл.
endif;
?>
Answer the question
In order to leave comments, you need to log in
all info here: https://codex.wordpress.org/Class_Reference/WP_Query
here is an example:
<?php
// the query
$the_query = new WP_Query( 'category_name=YOUR_CATEGORY' ); ?>
<?php if ( $the_query->have_posts() ) : ?>
<!-- pagination here -->
<!-- the loop -->
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php endwhile; ?>
<!-- end of the loop -->
<!-- pagination here -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question