• hi,
    im trying to have a list of posts from certain categories,
    like an index…

    i want the category title first and a post title list second.
    im trying this multiple loop but i cant take the cat-name outside the loop (i dont want it repeated for every post title)

    <?php	$the_query = new WP_Query( 'category_name=maschi alto rendimento'  ); ?>
    		<ul>
    			<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    			<li>
    				<?php the_title();?>
    			</li>
    			<?php endwhile; ?>
    		</ul>
    
    		<?php // i know this is wrong the_category();?>
    
    		<?php wp_reset_postdata();?>

    im thinking maybe i can use query posts? i dont know

    thanks a lot

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mr.cello

    (@mrcello-1)

    i solved this avec

    <?php if (is_category()) { single_cat_title(); } ?>

    just before the loop and after the query

    Thread Starter mr.cello

    (@mrcello-1)

    nope not solved 😉
    it doesnt work

    Here a scheme of wat im trying to accomplish:

    CATEGORY NAME
    post title
    post title
    post title
    
    CATEGORY NAME
    post title
    post title
    post title
    
    CATEGORY NAME
    post title
    post title
    post title

    maybe with one single loop where i tell which categories i want in this page
    :>

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘post list from a category’ is closed to new replies.