0

adding this line of code and adjusting my if statement has damaged my links in the loop. I really don't understand why this has happened. What is wrong with the line of code?

        <?php $query = new WP_Query( array( 'post__not_in' => get_option( 'sticky_posts' ) ) ); ?>

          <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>

            <div class="posts__post">

                <article>
                    <a class="posts__post--preview" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                    <p class="posts__post--tag"><?php the_category('&nbsp;/&nbsp;'); ?></p>
                    <h1 class="posts__post--title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                    <p class="posts__post--meta"><?php echo time_ago(); ?></p>
                </article>   


            </div>

          <?php endwhile; else :?>

          <h1><?php _e('no post where found!','blog'); ?></h1>

        <?php endif; ?>

        </div>
  • Can you try wp_reset_postdata(); after your custom query code to see if it helps? – Ahmed Fouad Sep 21 '16 at 23:13
  • I added after endwhile and still no luck. – sam Sep 21 '16 at 23:21
  • 1
    How are the links damaged? Which links are damaged? In the loop or outside the loop? – czerspalace Sep 21 '16 at 23:33
  • In the loop. the_permalink() – sam Sep 21 '16 at 23:40
  • Yes, describe damage please. Or give us a live view at it. Is it broken? How it's displayed in the final source HTML of page? – Ahmed Fouad Sep 21 '16 at 23:44
0

I'm sorry. I didn't create a single.php file. In my learnings I have discovered that if no single.php file exist then Wordpress falls back to index.php. So the link were actually working but just using the same template. Again im sorry for wasting your time.

  • 2
    There is a plugin called "Theme Check" that is going to tell you exactly what your theme is missing. Might be worth installing. – sdexp Sep 22 '16 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.