Answer the question
In order to leave comments, you need to log in
Why is index.php displayed instead of single.php?
Hello!
I make my template on the Wordpress engine. I’m not strong in this, but I decided to try, so I do everything according to video lessons and information on the Internet. Stuck on displaying the post page. It seems that the URL changes and the page is reloaded, but index.php is displayed.
At the moment I have the following files associated with single.php:
<article>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=2&post_type=post&paged='.$paged.'&cat=4');
while ($wp_query->have_posts()) : $wp_query->the_post();
//Content
get_template_part('template-parts/content', get_post_format());
wp_reset_postdata();
endwhile;
?>
</article>
<div id="post-<?php the_ID(); ?>" <?php post_class('row new_article') ?>>
<div class="col-xs-12 col-sm-4 col-xl-3 no-gutters">
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink($post); ?>"><img class="post_thumbnails media-object" src="<?php the_post_thumbnail_url(); ?>" alt="Olaines 1.vidusskola - jaunumi"></a>
<?php endif; ?>
</div>
<div class="col-xs-10 col-xs-push-1 col-sm-8 col-sm-push-0 col-xl-9">
<h1 class="post_heading"><a href="<?php the_permalink($post); ?>"><?php the_title();?></a></h1>
</br>
<div class="excerpt">
<?php the_excerpt(); ?>
</div>
<a href="<?php the_permalink($post); ?>"><button type="button" class="btn btn-primary"><?php echo get_theme_mod('main_readmore_button'); ?></button></a>
</div>
</div>
<?php get_header(); ?>
<!--Slider-->
<?php
get_template_part('template-parts/slider');
?>
<!--Slider-->
<div class="line_gradient"></div>
<div class="container-fluid" id="news">
<div class="row">
<!--Main (news)-->
<div class="col-xs-12 col-sm-8">
<img class="media-object" id="img_newspaper" src="<?php bloginfo("template_url"); ?>/images/newspaper.png" alt="Olaines 1.vidusskola - jaunumi">
<h1 id="title_jaunumi"><?php echo get_theme_mod('main_news'); ?></h1>
<div id="line_gradient_news_top" class="line_gradient"></div>
<article id="post-<?php the_ID(); ?>" <?php post_class('new_article') ?>>
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=2&post_type=post&cat=4');
while ($wp_query->have_posts()) : $wp_query->the_post();
//Content
get_template_part('template-parts/content', 'single');
wp_reset_postdata();
endwhile;
?>
</article>
<div id="line_gradient_news_bottom" class="line_gradient"></div>
</div>
<!--Left sidebar-->
<?php get_sidebar(); ?>
<!--Left sidebar-->
</div>
</div>
<?php get_footer(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('new_article row') ?> >
<div class="col-xs-12 col-sm-4 col-xl-3 no-gutters">
<?php if ( has_post_thumbnail() ) : ?>
<img class="post_thumbnails media-object" src="<?php the_post_thumbnail_url(); ?>" alt="Olaines 1.vidusskola - jaunumi">
<?php endif; ?>
</div>
<div class="col-xs-10 col-xs-push-1 col-sm-8 col-sm-push-0 col-xl-9">
<h1 class="post_heading"><?php the_title();?></h1>
</br>
<div class="content">
<?php the_content(); ?>
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Most likely, you read the file up to the line get_template_part('template-parts/slider');
and after receiving the error, nothing is reproduced further.
The error is that you are already in the template-parts folder, which means you are trying to access the template-parts / template-parts folder
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question