• I want to make my page 3 shows the latest posts from the respective printed categories when I click on that category.
    I found a code that can only be fixed to determine the categories to be always the same as I do not need.

    Now, when I click on the category menu above link to expel link
    http://www.moja-stranica.com/?cat=3
    but it still shows me posts from these fixed categories, which was placed in the Loop

    Is there a possibility to load the above categories?

    <?php
    	$catquery = new WP_Query( 'cat=17&posts_per_page=3' );
    	while($catquery->have_posts()) : $catquery->the_post();
    ?>
    <div class="col span_1_of_3">
    		<?php if (has_post_thumbnail()) : ?>
    			<?php the_post_thumbnail(); ?>
    		<?php endif; ?>
    	<div class="box<?php echo $counter--; ?>">
    	<a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a>
    	<p><?php the_excerpt(); ?></p>
    	<a href="<?php the_permalink(); ?>"><h3>>> Pročitaj više <<</h3></a>
    	</div>
    </div>
    <?php endwhile; ?>
Viewing 6 replies - 1 through 6 (of 6 total)
  • <?php
    if (is_category()) {
    	$theCatID = get_term_by( 'slug', $wp_query->query_vars['category_name'], 'category' );
    	if (!empty($theCatID))
    		$theCatID = $theCatID->term_id;
    	if (isset($wp_query->query_vars['cat'])) $theCatID = (int)$wp_query->query_vars['cat'];
    }
    	$catquery = new WP_Query( 'cat='.$theCatID.'&posts_per_page=3' );
    	while($catquery->have_posts()) : $catquery->the_post();
    ?>

    I’m assuming you’re using the archive.php for this, otherwise say something.

    If you add this bit of code to check the query_var’s for the ?(&)cat= and then have the wp_query use that catID it will use it for the query

    Or, if anything you can see how it’s done in this example

    ..writing from memory so you probably want to adjust that a little

    Thread Starter RickyCro

    (@rickycro)

    Thanks man.

    This works.

    Thread Starter RickyCro

    (@rickycro)

    Hmm

    how to do same thing for tags?

    This really has to be a case of #yourdoingitwrong

    Please, tell me .. is it for the archive.php ? and your goal is to limit it to 3 posts displayed at a time avoiding the settings -> reading of 10 at a time?

    What’s the goal here

    Thread Starter RickyCro

    (@rickycro)

    The first thing was to category.php

    You don’t need a loop. The loop is already created for you when you go to one of the archive.php category.php and taxonomy.php type template files that are called automatically

    The ‘amount’ to display is handled in the settings -> reading

    the archive.php can facilitate all of them under one roof. to which case you can grab almost any archive.php from any theme and take a look at how it’s done

    mine is here:
    https://github.com/Frumph/comicpress/blob/master/archive.php

    Which is a bit more uhm, extravagant then most.

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

The topic ‘[Category problem] Posts from some category’ is closed to new replies.