• So I’ve been reading for a while on how to use prev and next links on my single pages. I have custom post type that is called portfolios and 2 categories. Now when i try to use:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    				<?php previous_post_link('%link', '<h6 class="hidden-sm-down">'.'%title'.'</h6><h6 class="hidden-md-up">'.'%title'.'</h6>', TRUE); ?>
    				<?php next_post_link('%link', '<h6 class="hidden-sm-down">'.'%title'.'</h6><h6 class="hidden-md-up">'.'%title'.'</h6>', TRUE); ?>
    			<?php endwhile; else : ?>
    			<?php endif; ?>

    i get all posts, they are not filtered.

Viewing 1 replies (of 1 total)
  • Try this:
    `$args = array(
    ‘category_name’=>’category-name’,
    ‘posts_per_page’=> 10,
    );
    $query = new WP_Query($args);
    if ($query->have_posts()) {
    while ($query- >have_posts()): $query->the_post(); ?>
    <div class=”thumbnail”>
    <?php if (has_post_thumbnail()) {
    the_post_thumbnail(‘featured’);
    } ?>
    <div class=”caption caption-content”>
    <h3 class=”product-name”><?php the_title(); ?></h3>
    <p class=”text-muted”>
    <strong>???????:</strong> <?php the_author();?>
    ?? ?????: <?php the_date(); ?></p>
    <p> <?php the_excerpt(); ?> </p>
    <div>

    </div>
    </div>
    <hr>
    </div>
    <?php endwhile;
    }`

Viewing 1 replies (of 1 total)
  • The topic ‘How to filter posts by category?’ is closed to new replies.