• Hi there. I don’t know what I’m doing. Is anybody using David Chait’s list_posts_of_cat hack in version 1.2?
    I’m trying to use it outside the loop, and I just can’t figure out how to feed it. I want to display a list of the entries in category 2.
    I’ve tried
    echo list_posts_of_cat(array("2"),5,5);
    echo list_posts_of_cat(2,5,5);
    echo list_posts_of_cat(array("category_id" => "2",5,5);
    I’ve even tried
    echo list_posts_of_cat(get_the_category($cat='2'), 5, 5);
    And all sorts of other ludicrous stuff. What can I say? I’m an artist.
    All I get is “No Matching Entries”, and there are! There are! Can anybody help me?
    Cheers,
    Anthony

Viewing 4 replies - 1 through 4 (of 4 total)
  • Well, since I actually tested it under 1.2alpha, weird it wouldn’t work! ??
    Lemme go take a look…
    -d

    Okay. In the posts loop, I use something like:
    echo list_posts_of_cat(get_the_category(), 3, 0, $post->ID);
    For a sidebar, I use something like:
    echo list_posts_of_cat(get_the_category(), 3, 3);
    However, I only use sidebars in single-post pages (where get_the_category is ‘proper’ and valid).
    There is functionality missing majorly from the category system at the moment — at least in my few-weeks-old 1.2 drop. The whole category system is missing important caching and lookup functions that I have written myself…
    Unfortunately, you really want a function list “get_category”, that returns the same block of data get_the_category does, but takes an ID. Or, modify get_the_category to take an $id=0 parameter, and pass in the category ID when you’ve got a custom one to lookup… I wrote the same_cat code originally to take get_the_category’s results in particular, which is why it functions the way it does.
    SO, screw it! I just reworked the function quickly so you can now pass it a SINGLE category ID as a param instead of the complex data array structure, like:
    echo list_posts_of_cat(2, 5, 5);
    .. using your example.
    It’s up on my site.
    -d

    Thread Starter ajlitton

    (@ajlitton)

    Thank you. You are my new favourite person.
    David Chait, everybody!
    Anthony

    Always happy to help!
    -d

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Help with list_posts_of_cat’ is closed to new replies.