• Kittens show_categories plugin no longer works in 1.5 and she isn’t planning an update because of the functionality now built into 1.5. Can someone provide me an example of how 1.5 can natively show or hide specific categories of posts, e.g. so I can create separate zones for different categories of posts on my front page? … Many thanks

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter essdsm

    (@essdsm)

    I can’t find any integration of Kitten’s show/hide categories plugin in 1.5, which is a bit of suprise (it may just be me not looking hard enough). Anyway, in the absence of an apparent solution I’ve made minor modifications to her show_categories plugin which appears to make it compatible with WP 1.5.

    It seems to have been a table variables issue, i.e. changing all references to $tableposts to $wpdb->posts and $tablepost2cat to $wpdb->post2cat appears to have done the trick. I think that the global variable declarations for $tableposts and $tablepost2cat at the top of both plugin functions were no longer relevant so I removed them. I suspect WP1.5 contains native functions which could improve the efficiency of the script for parsing the cats array but I’ll leave that job to someone who knows 1.5 better than me:)

    I include the modified show_categories plugin script below. It would be nice to find this as standard WP functionality in the near future (or that I was wrong and it’s actually already there but undocumented) because it increases template design flexibility no end.

    [Moderated: Script code removed. Please use https://paste.uni.cc to post long code examples.]

    Anyone else tried this and had it work in 1.5?

    Basically, the trick w/ 1.5 is to use the is_category( $num ) function in an if statement to wrap your main loop. You can also negate it to exclude a category.

    Thread Starter essdsm

    (@essdsm)

    Kitten … Thanks for this but I’m afraid there’s a bit of a conceptual leap for happening here. The barebones example of the 1.5 loop in the codex would benefit from just such an example. Could you possibly illustrate what you mean?

    I guess I’d like to ask for an illustration of how to do this in 1.5 if it’s possible, too. Thanks!

    https://codex.www.ads-software.com/The_Loop now has an example dealing with styling the post content differently if the post belongs to a certain category. The example is tailored to version 1.5.

    A similar technique could be used to display only certain categories.

    Ok, the example was half baked. It should work now.

    And now there’s an example for what you actually want!

    Thanks so much!

    knitter

    (@knitter)

    I have managed to create the effect that I want using the last example code posted by Ryan in the first part of the advanced use info on the Loop https://codex.www.ads-software.com/The_Loop and it is working but I have to questions.

    1) are there more parameters I can use, in particular to sort the result by name or id?
    2) how do I exclude the posts that are from child categories of the cat I have specified?

    thanks!

    elephantwoman

    (@elephantwoman)

    Try

    orderby=title&order=ASC

    For reference, this works for me (xxx what you whant) :

    <?php query_posts("category_name=xxx&orderby=title&order=
    ASC&showposts=xxx"); ?>
    <?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>

    knitter

    (@knitter)

    thanks! any ideas on removing the posts of child categories?

    elephantwoman

    (@elephantwoman)

    Ia€?m afraid none.

    It should be simple, when using “cat=xx” to tell wp to exclude other categories other than xx but I really don’t see how.

    (For reference, if ID is prefered then “cat” instead of “category_name”. And for showing all posts “showposts=-1”)

    knitter

    (@knitter)

    thanks for that! i had figured out how to use id with some fiddling round but hadn’t figured how to show all (other than setting a high limit I knew wouldn’t be crossed). I shall have to rethink my category structure… I had this all working beautifully with Kitten’s plugin, it seems to me that it is not so redundant after all…

    I used the is_category function to hide the category, but on the index page, the navigation is somehow still counting the posts from the hidden category. So I get a blank page. How do I fix the page navigation code?

    see https://blog.counterjumper.com

    the category I have hidden is Images

    I’m using the code found here https://codex.www.ads-software.com/The_Loop#Exclude_Posts_From_Some_Category to exclude a category (the one it says is OK to use without a new category archives template) and I’m getting an error:


    Parse error: parse error, unexpected T_ENDWHILE in /home/kartlink/public_html/pro/wp-content/themes/gentle_calm/index.php on line 44

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘WP 1.5 show/hide categories’ is closed to new replies.