List Category Posts WordPress Plugin support
  • FernandoFernando October 2009
    Posts: 306
    This is a topic for users of List Category Posts to post their questions on how to use, hack or acheive new workarounds on the plugin.

    If you consider it necessary, feel free to open a new topic on the WordPress forum about List Category Posts.

    image
  • Glass4242Glass4242 November 2009
    Posts: 1
    Hi,

    I had been looking for an answer to a question I had and the answer WAS in the comments but since they were removed, I can't find the answer now.

    The problem I am having is that when the plugin generates the list, it also puts the pages that the list is on IN the list. Can this be disabled or removed?
  • levivleviv November 2009
    Posts: 1
    Hey yo Glassy and Nando...

    Here is the fix for the offset that Glassy is asking about...

    Glassy, what you really mean is that the posts that are listed are those which are already been showed, so in order to avoid that I reprogrammed the plugin to use the offset function of the :

    Offset Parameter

    You can displace or pass over one or more initial posts which would normally be collected by your query through the use of the offset parameter.

    The following will display the 5 posts which follow the most recent (1):

    query_posts('posts_per_page=5&offset=1');

    as stated in the wp CODEX site:

    http://codex.wordpress.org/Template_Tags/query_posts#Parameters
    Scroll all the way down to offset..

    So the fix is to add a new parameter:

    'offset' => '4',

    and to send that parameter to the query_post():

    '&offset=' . $atts['offset'] );


    and to add that parameter to the code:

    [catlist ID=1 numberposts=5 excerpt=yes date=yes offset=4]

    This will list all the post starting at the 4th post on the cat id 1, all you need to do is.. can you count?

    The final fix to the plugin shows as follows:

    function catlist_func($atts, $content=null) {
    $atts=shortcode_atts(array(
    'id' => '0',
    'name' => 'default',
    'orderby' => 'date',
    'order' => 'desc',
    'offset' => '4', //Permite especificar un offset para comensar a listar los posts, contribucion por Levi Vasquez
    'numberposts' => '5',
    'date' => 'no',
    'author' => 'no',
    'dateformat' => get_option('date_format'), //By Verex
    'template' => 'default',
    'excerpt' => 'no',
    'exclude' => '0'
    ), $atts);
    return list_category_posts($atts);
    }
    add_shortcode('catlist', 'catlist_func');

    function list_category_posts($atts){
    if($atts['name']!='default' && $atts['id']!='0'){
    $category = 'category_name=' . $atts['name'];
    }else{
    $category = 'cat=' . $atts['id'];
    }
    //Build the query for get_posts()
    $catposts = get_posts($category.'&numberposts=' . $atts['numberposts'] .
    '&orderby=' . $atts['orderby'] .
    '&order=' . $atts['order'] .
    '&offset=' . $atts['offset'] ); //Permite especificar un offset para comensar a listar los posts, contribucion por Levi Vasquez

    Cheers mates!!!!

    Levi.
  • FernandoFernando November 2009
    Posts: 306
    Levi:
    Thanks a lot for your code. :pene:

    I'll add this on a future release of List Category Posts.

    Regards!
  • alfirinalfirin November 2009
    Posts: 1
    Hi!

    For everyone using Qtranslate in their websites, here is a way to make List Category Posts Plugin with multilingual support to show the correct part of the post title in each language version.

    In list_cat_posts.php add this line

    $catposts = __($catposts);

    at the end of

    //Build the query for get_posts()
    $catposts = get_posts($category.'&numberposts=' . $atts['numberposts'] .
    '&orderby=' . $atts['orderby'] .
    '&order=' . $atts['order']);
    $catposts = __($catposts);


    It works perfect for me. Thanks for this great plugin!

    Cheers,
    Milena from Hubavo - Interaction Design Studio
    http://hubavo.com
  • lzernerlzerner November 2009
    Posts: 2
    There is a simple but serious bug in the handling for the name attribute. See lines 48-52:

    48 if($atts['name']!='default' && $atts['id']!='0'){
    49 $category = 'category_name=' . $atts['name'];
    50 }else{
    51 $category = 'cat=' . $atts['id'];
    52 }



    This says, if the "name" attribute has been explicitly set and the "id" attribute has also been set, then use the category_name, otherwise, use the category ID. That's contrary to the documentation, which says:

    [quote]If you use both arguments (wrong!), List Category Posts will show the posts from the category in 'name'.

    In the above implementation, if you set both arguments, List Category Posts shows the posts from the category in "id" instead.

    It's very bad, though, if you provide only the "name" argument. In this case, since $atts['id'] is still '0', you skip line 49 and instead execute line 51: $category = 'cat=' . $atts['id']; The result is that you see all posts listed from all a categories.

    In other words, the "name" argument doesn't ever work. The only way to restrict the category in your current implementation is to use the "id" argument.

    The fix to this is very simple. In line 48, change $atts['id']!='0' to $atts['id']=='0' (change from "not equal" to "equal"), so the whole line is:

    48 if($atts['name']!='default' && $atts['id']=='0'){

    In this case it will behave as you documented it.

    In a subsequent post, I will provide an enhancement to your code that allows the inclusion of post content on the page as an alternative to the post excerpt.

    Thank you for a wonderful little plugin that has perfectly solved my requirement to put category listings into the page navigation.

    Lang Zerner
    http://www.studio32.com/
  • lorenzovlorenzov December 2009
    Posts: 1
    Do you plan to make it compatible with the 2.8.6 wp release?
  • btrcbtrc December 2009
    Posts: 1
    Hi great plugin.

    I wonder if it is possible to included custom fields in the output.

    I am working on a cooking site, pages are ingredients and posts are recipes.

    Each post has a thumbnail image in a custom field I use the below code to show 2 thumbs from a catagory on the index page.

    So I will have one for each main type of meat, chicken, beef, pork etc and the index will show the links to the two most recent recipes.

    <?php query_posts('cat=30&showposts=5'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark">
    <?php
    $food_img = get_post_meta($post->ID, "food_img", true);
    if ($food_img != "")
    {
    $food_img = explode(",", $food_img);
    foreach ($food_img as $picture)
    {
    echo "<img alt=\""; the_title(); echo"\" src='" . $picture . "' />";
    }
    }
    ?>
    </a>
    <?php the_time('F j, Y'); ?>
    | <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?>
    </a>
    <?php endwhile; else : ?>
    <?php endif; ?>


    What I want to do is incorporate part of this code in to the plugin.

    I think it will be this part
    <?php
    $food_img = get_post_meta($post->ID, "food_img", true);
    if ($food_img != "")
    {
    $food_img = explode(",", $food_img);
    foreach ($food_img as $picture)
    {
    echo "<img alt=\""; the_title(); echo"\" src='" . $picture . "' />";
    }
    }
    ?>


    Then the output will show the clickable recipe thumbs with the recipe name set as img title. I guess it will have to be made part of the array.

    Then I will have one at the bottom of each page listing all recipes featuring that ingredient.

    I think I will need to make the template code

    <img title=\""; the_title(); echo"\" src='" . $picture . "' />

    Now I don't know much phpp but I am thinking that I need to add the below code somewhere around line 51-52 of list_cat_posts.php

    $food_img = get_post_meta($post->ID, "food_img", true);
    if ($food_img != "")
    {
    $food_img = explode(",", $food_img);
    foreach ($food_img as $picture)


    Am I going in the right direction with that idea.

    cheers
  • FernandoFernando December 2009
    Posts: 306
    Just a heads up to tell the users of the plugin I'm moving into a new city (new city, new job, etc.) so I'm having very little time on my computer. I'll do a major update with some new features and recoding as soon as I get some time on my hands to sit down and write the code. Some cool new features on WP 2.9...

    Thanks for using the plugin and posting your feature requests / ideas here, they are very useful and I'll try to code them all.

    Merry Christmas and Happy New Year! :|
  • FernandoFernando December 2009
    Posts: 306
    Version 0.7 is out with new features and bug fixes, hope you like it.
  • janejane April 2011
    Posts: 1
    alfirin said:

    Hi!

    For everyone using Qtranslate in their websites, here is a way to make List Category Posts Plugin with multilingual support to show the correct part of the post title in each language version.

    In [b]list_cat_posts.php[/b] add this line

    [code]$catposts = __($catposts);[/code]

    at the end of

    [code] //Build the query for get_posts()
    $catposts = get_posts($category.'&numberposts=' . $atts['numberposts'] .
    '&orderby=' . $atts['orderby'] .
    '&order=' . $atts['order']);
    $catposts = __($catposts);[/code]

    It works perfect for me. Thanks for this great plugin!

    Cheers,
    Milena from Hubavo - Interaction Design Studio
    http://hubavo.com



    I have not been able to find this code in the current version of List Category Posts and therefore I have the list of links in both languages. Please can someone tell me what to edit to ensure the list is in either language [using Qtranslate]
    Many thanks, Jane
  • danicasatidanicasati October 2011
    Posts: 3
    I can't find the code too.
    Any help about it?
  • danicasatidanicasati October 2011
    Posts: 3
    Ok, you can use this hack only with version 0.13.1 or lower.
    Have a nice day!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with OpenID Sign In with Twitter Sign In with Google

Sign In Apply for Membership

In this Discussion

This Site is currently in maintenance mode.
Please check back here later.
→ Site Settings