Category Page

  • rickhellewell

    #8584

    How do I create a page of posts in one category?

    Thanks…Rick…

    Mod

    Kenneth John Odle

    #41540

    You can use the category archive, or you can use a plugin such as Kalin’s list plugin.

    rickhellewell

    #41541

    …except the “Kalin plugin” has been abandoned.

    How about a template that looks at a custom field that contains additional WPQuery parameters. This shouldn’t be too hard to add to the theme.

    This custom-query would just add to the current WPQuery in the existing templates. And it would be an excellent feature to add, since there don’t seem to be many custom-query plugins that work with themes.

    …Rickc…

    Mod

    Kenneth John Odle

    #41543
    Quote:
    …except the “Kalin plugin” has been abandoned.

    It’s fairly lightweight, and still works for me in 3.8/1.9.2. But this is a valid concern, especially with the rate they are updating WordPress.

    However, there is the Advanced Post List plugin, which picks up where Kalin’s left off.

    What’s wrong with just using the category archive? What are you trying to achieve that can’t be satisfactorily handled by WordPress’s built-in category archive?

    Quote:
    This shouldn’t be too hard to add

    LOL. If I had a dollar for every time someone said this, I could be retired and living on my own private island.

    rickhellewell

    #41544

    This code could be added to your templates. The user would create a custom_query variable and values called “custom_query”. The parameters (values) of that variable would be additional WPQuery parameters. This additional code would read the variable on a page, parse the values, add the values to the WPQuery arguments.

    This example code would be placed before the ‘loop’ and before the WPQuery in the template.

    <?php

    // rough code to use a custom_query value on a page to modify the WPQuery parameters
    // used in a page
    // this code should be placed before the loop that displays the poasts

    // any WPQuery parameter could be used in this code, as needed

    // this variable would be added to a "Category" page.

    // custom_query = contains the additional wpquery parameters
    // ex: custom_query = count=10&catid=12
    // would show 10 posts with the categoriy ID number of 12

    // code is added to the template just before the WPQuery is done

    // this part reads the custom_query values from the page
    $graphene_query_args = get_post_meta($post->ID, 'custom_query', true);
    // check for the parameters in the custom_query value
    if ($graphene_query_args != '') { // check if there are values

    switch (true) {
    // for each possible parameter, decode it an add it to the WPQuery array
    case (get_query_var('count')) : $count = get_query_var('count');
    $graphene_query_args = $graphene_query_args . "&count=$count";
    break;
    case (get_query_var('catid')) : $catid = get_query_var('catid');
    $graphene_query_args = $graphene_query_args . "&catid=$catid";
    break;
    // add more case commands for each possible query parameter
    }
    // end of checking the values
    }
    // add additional default WPQuery parameters used by default in the template

    // do the query based on the custom_query parameters
    query_posts($graphene_query_args);

    ?>

    I can send a dollar towards your ‘island retreat’…… <grin>

    …Rick…

Viewing 5 posts - 1 through 5 (of 5 total)

  • You must be logged in to reply to this topic.