Answer the question
In order to leave comments, you need to log in
How to display post title in wordpress?
Hello! Please explain how to display the title of the posts through the Yoas seo plugin? The title of the pages on the tabs are displayed, but the entries do not want to. I have all the entries displayed on the main page one by one (you can scroll them back and forth). So the title of this page is displayed, but I need to display the title of the posts as well. When I edit a post and view it, everything works. What am I missing?
Here is the code where the articles are displayed. Maybe the problem is in the loop or pagination?
<?php
// Template Name: Главная
get_header();
?>
<div class=" wrapper container">
<section>
<div class="content">
<?php
global $query_string;
query_posts( $query_string . "&order=ASC" );
if ( have_posts()) : while ( have_posts()) : the_post();
?>
<article class = "wrapper_content">
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
</article>
<?php
endwhile;
wp_reset_postdata();
endif;
?>
<div class="pagination">
<ul>
<?php if( is_user_logged_in() ) { ?>
<li class="nav-next"><?php previous_posts_link( 'Предыдущая страница' ); ?></li>
<li class="nav-previous"><?php next_posts_link( 'Следующая страница' ); ?></li>
<?php } else if ( get_query_var('paged') == 4 ) { ?>
<li class="nav-next"><?php previous_posts_link( 'Предыдущая страница' ); ?></li>
<?php wp_nav_menu('menu_class=bmenu&theme_location=bottom'); ?>
<?php } else {?>
<li class="nav-next"><?php previous_posts_link( 'Предыдущая страница' ); ?></li>
<li class="nav-previous"><?php next_posts_link( 'Следующая страница' ); ?></li>
<?php } ?>
</ul>
</div>
</div>
</section>
<?php get_footer(); ?>
Answer the question
In order to leave comments, you need to log in
This helped me in this case. Inconsistencies were found.
Loop: remove global and wp_query
<?php
// Template Name: Главная
get_header();
?>
<div class=" wrapper container">
<section>
<div class="content">
<?php
if ( have_posts()) : while ( have_posts()) : the_post();
?>
<article class = "wrapper_content">
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
</article>
<?php
endwhile;
wp_reset_postdata();
endif;
?>
<div class="pagination">
<ul>
<?php if( is_user_logged_in() ) { ?>
<li class="nav-next"><?php previous_posts_link( 'Предыдущая страница' ); ?></li>
<li class="nav-previous"><?php next_posts_link( 'Следующая страница' ); ?></li>
<?php } else if ( get_query_var('paged') == 4 ) { ?>
<li class="nav-next"><?php previous_posts_link( 'Предыдущая страница' ); ?></li>
<?php wp_nav_menu('menu_class=bmenu&theme_location=bottom'); ?>
<?php } else {?>
<li class="nav-next"><?php previous_posts_link( 'Предыдущая страница' ); ?></li>
<li class="nav-previous"><?php next_posts_link( 'Следующая страница' ); ?></li>
<?php } ?>
</ul>
</div>
</div>
</section>
<?php get_footer(); ?>
add_action( 'pre_get_posts', 'function_post' );
function function_post($postAsc) {
if (!is_admin() && $postAsc->is_main_query()) {
if ( is_home() ) {
$postAsc->set( 'posts_per_page', 1 );
$postAsc->set( 'orderby', 'date' );
$postAsc->set('order', "ASC");
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question