Trouble with editing template for “List category posts” plugin

WP 3.0.4
local installation, multisite network enabled
theme: Twentyten
plugin: List Category Posts v .15, network activated

I’ve created the folder list-category-posts inside my theme folder, and placed default.php inside it. Edited default.php and saved as lcp_template_1.php inside same folder. However, the changes are not appearing at all. I’m trying to change the style of the lcp output from the default <ul> to <div> classes defined in my theme (child)’s style.css. NOT WORKING.

Read More

That is, the plugin is functioning, but the style changes are not working.

Code for my template file is up at http://wordpress.pastebin.com/EGmrkerQ

Please help. Sorry, no url for viewing the output, because this is a local installation.

Oh, btw, I should mention that in the shortcode I have called for the new template, as follows: [catlist id=1 template=lcp_template_1].

Related posts

Leave a Reply

2 comments

  1. 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 😀

  2. Shortcode: [catlist template=lcp_template_1 id=9 orderby=date numberposts=1 date=yes author=yes excerpt=yes catlink=yes thumbnail=yes ]

    In the plugin folder > list_cat_posts.php, these are the instances for ‘thumbnail’:

    File list_cat_posts.php; line 56:
    ‘thumbnail’ => ‘no’,

    File list_cat_posts.php; line 168: if
    ($atts[‘thumbnail’]==’yes’){

    File list_cat_posts.php; line 169:
    $lcp_display_output .=
    lcp_thumbnail($single);

    File list_cat_posts.php; line 229: *
    @see
    http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

    File list_cat_posts.php; 232: function
    lcp_thumbnail($single){

    File list_cat_posts.php; line 233:
    $lcp_thumbnail = ”;

    File list_cat_posts.php; line 234: if
    ( has_post_thumbnail($single->ID) ) {

    File list_cat_posts.php; line 235:
    $lcp_thumbnail =
    get_the_post_thumbnail($single->ID);

    File list_cat_posts.php; line 237:
    return $lcp_thumbnail;

    And in my template, these are the instances for ‘thumbnail’:

    //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>’; }

    So there is no misspelling, as far as I can see. I had already seen the forum thread you’re referring to, and made the correction to the default template.

    The thumbnail is displaying as expected in the original post, so I don’t know why LCP is not pulling it along with the post. Unless it doesn’t do that with excerpts?