0

Let me tell details about what I am trying to do,

I have one category call Members this category show in custom category file. and in category page show featured images with <?php the_permalink(); ?> so when I click thumbnail image it go to single.php file this is WordPress system for this Members category post I have one custom template also. which define in single.php bellow is code

<?php
get_header(); ?>
<div class="contentarea cf">
  <?php while ( have_posts() ) : the_post(); ?>
  <h3>
    <?php the_title(); ?>
  </h3>
  <?php
    if ( in_category( 'members' ) ) {
         get_template_part( 'content', 'members' );
    } 

    else {
        get_template_part( 'content', 'common' );
    }
 ?>
  <?php endwhile;  ?>
</div>
<?php get_footer(); ?>

so when Members post open its go to content-members.php file and show post. but now I want in this page will show all Members post not only one post. I can't figure out yet how to do that.

1 Answer 1

0

Using The Loop with the required arguments should list all the posts. An Example:

$temp = $wp_query;
     <?php
        $type = 'post_type';
        $args = array (
        'post_type' => $type,
        'post_status' => 'publish',
        'paged' => $paged,
        'posts_per_page' => 20,
        'ignore_sticky_posts'=> 1
         );
        $temp = $wp_query; // assign ordinal query to temp variable for later use
        $wp_query = null;
        $alt = false;
        $wp_query = new WP_Query($args);
          if ( $wp_query->have_posts() ) :
while ( have_posts() ) : the_post(); 
  {
  the_title();
  }
  end while;
  endif;
 $wp_query = $temp; /* This is a must to make your template work properly

I hope this helps!

10
  • i not really undertand where i put this code and how to get title content feature image... etc
    – pagol
    Commented Aug 19, 2013 at 9:39
  • You put that code right after <?php get_header(); ?> <div class="contentarea cf"> Also i have edited my answer to how to retrive the post tile with the_title() function.
    – sri
    Commented Aug 19, 2013 at 9:43
  • @thanks sri.. but i think i can't tell properly or you don't understand clearly... actually the code you are seeing now that in single.php page.. this page have no problem... from this call members page (content-members.php) if that post from members category. we need something in members page. its blank now.. i need show this all members category post...
    – pagol
    Commented Aug 19, 2013 at 10:01
  • Oh sorry my mistake. Please use the code i gave you on content-members.php file.
    – sri
    Commented Aug 19, 2013 at 10:12
  • its ok. @sri.. but show syntex error... would you check please again.
    – pagol
    Commented Aug 19, 2013 at 11:00

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.