Trouble with editing template for “List category posts” plugin

Hey you just opened the plugin’s tag on WordPress Answers šŸ˜€

Can you paste the code of the generated html? From what you describe, you are using it correctly, so I just want to see if the template is being loaded to detect if the problem is on the template side, or a bug on the plugin’s code.

UPDATE: Ok, I checked your template on a new WordPress install. It was getting the template, but there was some code error, here’s what worked for me:

I created the list-category-posts folder under wp-content/themes/twentyten and added a new php file called “lcp_template_1.php” with your code. Then created a new post with:

[catlist template=lcp_template_1]

Now, I started editing your template, I fixed the Show Category code and it’s currently working with this code:

<?php
/*
Plugin Info & license stuff...
*/
$lcp_output="";    
//Show category?
    if ($atts['catlink'] == 'yes'){
        $cat_link = get_category_link($lcp_category_id);
        $cat_title = get_cat_name($lcp_category_id);
        $lcp_output="<div class="topic-heading"><a href="" . $cat_link . '" title="' . $cat_title . '">' . $cat_title . '</a></div>';
    }
$lcp_output .= '<div class="post">';//For default ul

//Posts loop:

foreach($catposts as $single):
    $lcp_output .= '<h2 class="entry-title"><a href="' . get_permalink($single->ID) . '">' . $single->post_title . '</a></h2>';
    //Show comments?
    if($atts['comments'] == yes){
        $lcp_output .= ' (' . $single->comment_count . ')';
    }
    //Style for date:
    if($atts['date']=='yes'){
        $lcp_output .= ' <div class="entry-meta"> ' . get_the_time($atts['dateformat'], $single) . '</div>';
    }
    //Show author?
    if($atts['author']=='yes'){
        $lcp_userdata = get_userdata($single->post_author);
        $lcp_output .=' <div class="entry-meta">' .$lcp_userdata->display_name . '</div>';
    }
    //Show thumbnail?
    if($atts['thumbnail']=='yes'){
        $lcp_output .= '<div class="lcp_thumbnail"><a href="' . get_permalink($single->ID) . '">' . get_the_post_thumbnail($single->ID, array('40','40')) .'</a></div>';
    }

    //Show content?
    if($atts['content']=='yes' && $single->post_content){
        $lcpcontent = apply_filters('the_content', $single->post_content); // added to parse shortcodes
        $lcpcontent = str_replace(']]>', ']]&gt', $lcpcontent); // added to parse shortcodes
        $lcp_output .= '<p>' . $lcpcontent . '</p>'; // line tweaked to output filtered content
    }
    //Show excerpt?
    if($atts['excerpt']=='yes' && !($atts['content']=='yes' && $single->post_content) ){
        $lcp_output .= lcp_excerpt($single);
    }
    endforeach;
$lcp_output .= '</div>';
?>

Please let me know if this works for you. I should update the default template since the show category code is old and buggy. Will be done for next version.

UPDATE: 0.15.1 includes a fix for the undeclared lcp_output variable. Also, regarding the thumbnail not displaying, please make sure you’ve modified the theme according to the get_the_post_thumbnail documentation.

To enable post thumbnails, the current
theme must include add_theme_support(
‘post-thumbnails’ ); in its
functions.php file. add_theme_support(
‘post-thumbnails’ ); must be called
before the init hook is fired. That
means it needs to be placed directly
into functions.php or within a
function attached to the
after_setup_theme hook.

SOLVED:

As we found out on the comments, the problem was with using STYLESHEETPATH instead of TEMPLATEPATH. This change will be included on the next release. Thanks Das for the feedback šŸ˜€