0

Good day,

I was trying to show a specific post when a user click on the title but all other post are shown as well, how can I filter it?

for example when I click link http://levelup.sic.edu.ph/archives/students/post-no-2 the other post are shown as well.

or How do I get the title from the link so I could use it as my parameter on my query?

here's my single-students.php

<?php
/**
* The Template for displaying all single posts.
*
* @package Motif
*/

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

    <?php query_posts( 'post_type=students'); ?>

    <?php while ( have_posts() ) : the_post(); ?>

        <?php get_template_part( 'content', get_post_format() ); ?>

    <?php endwhile; // end of the loop. ?>

    </main><!-- #main -->
</div><!-- #primary -->

1 Answer 1

1

query_posts( 'post_type=students'); that changes the main query to be for all posts with the type students. It's showing all the posts because you're asking it to.

If this is on a single post page, your loop will be sufficient, no need for extra query_posts calls or anything like that. Just remove that bit from your code.

In fact, you probably shouldn't use query_posts at all.

1
  • lol. that was a stupid mistake of mine sir.. thank you for correcting that :) really helped me. Thank you sir.
    – melvnberd
    Jan 4, 2015 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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