List Category Posts - Using templates
  • FernandoFernando May 2010
    Posts: 306
    Templates for the List Category Plugin are searched for in your WordPress theme's folder. You should create a folder named list-category-posts under 'wp-content/themes/your-theme-folder'.

    Template files are .php files.

    You can use the included template as an example to start. You can find it in the plugin's template folder under the name default.php. To use a template, use this code:
    [catlist id=1 template=templatename]
    If the template file were templatename.php.

    You can have as many different templates as you want, and use them in different pages and posts. The template code is pretty well documented, so if you're a bit familiar with HTML and PHP, you'll have no problems creating your own template. I'm planning on reworking the template system in order to have a really user friendly way to create templates, but in the meantime, I'm slowly improving the existing system.

    More info / help.

    SUPPORT THE PLUGIN
    If you would like to support the development of List Category Posts, or just thank me for the development, you can check these two links: My Amazon Wishlist - Donate via PayPal - Find the PayPal "Donate" button, and donate any ammount.
  • saintnekosaintneko July 2010
    Posts: 1
    Wow, the template system was just what I needed!! In fact, I was considering contacting you about ways to build in options so I could customize the display without hacking the PHP source, and it appears you've saved me even that trouble!

    trabajo impresionante! (I asked google how to say that in spanish so forgive me if it's horribly wrong) I'll donate a few bucks when I'm not spending every last penny on food and shelter (work is not so easy to find in my place in America these days).
  • FernandoFernando August 2010
    Posts: 306
    Glad you liked it. It works for now, but it still needs some hacking. I'm thinking of simplifying the whole system, in order to use some short code or something.

    The idea is:
    The user would just have to write a PHP file with HTML and "short codes" in order to use whatever style she wants:
    <h3>[category title]</h3>
    <li>[post title] - [comments] [date] [author]</li>

    And then have the plugin replace these codes with the expected values.

    Thanks for the "impressive work" :domo:
    Good luck with finding a job!
    Regards
  • montalutmontalut August 2010
    Posts: 1
    Hola Fernando!
    I just installed the plug in as a sidebar widget for my site, metrorealty.ph (works wonderfully, thank you! :D ), but I would also like to encode it into the main area of the homepage, right under the featured content section. The site uses an existing template (agent theme by studio press).

    I tried to copy-paste the php code of the default.php file, but can't figure out where to specify which category to pull. I hope you can help!

    Mil gracias,
    Johanna
  • FernandoFernando August 2010
    Posts: 306
    You can create a widget under the featured content or use the shortcode inside a page.

    Widgetizing Themes might help you out if you want to add a new widget zone in your theme.

    Regards!
  • BritzinozBritzinoz August 2010
    Posts: 7
    Using a template, is it possible to have one category hard coded into the template, and then have another category selected by the normal method, meaning that only posts fitting "both" categories together will be selected ?

    eg: hard code category 5 = preselect all category 5 posts
    select category 8 by nornal [catlist id=code] = select from above cat 5 posts, all the cat 8 posts.

    If so, how would the category hard code be added into the template?

    Thanks
  • LeeLee September 2010
    Posts: 1
    Hi,

    Really loving this plugin, pefect for what I need. I simply can't get the templates to work at all. I am using the following in my page:
    [catlist name=Blog excerpt=no orderby=date numberposts=10 template=default1]

    I have created a file called default1.php and placed it into wordpress/wp-content/plugins/list-category-posts/templates however its just not working. I check the source code of the page and it still displays the original layout.

    Any ideas?

    THanks

    :sw1: :domo: :google:
  • grungyparadigmgrungyparadigm September 2010
    Posts: 2
    I am using your plugin, and it is perfect for what I need it for! I am using it on my page http://www.grungyparadigm.com/poetry and the one thing I can't figure out is templates. I want to put a horizontal line in between each post that I filtered to the "poetry" page. Is this where I would use a template to add the horizontal line? I added the default category, renamed it "grungy.php" and directed the short code to it:

    "[catlist name=poems template=grungy numberposts=50 content=yes]"

    But I don't know how to change the code in the template to include the horizontal bar. Any suggestions?
  • BritzinozBritzinoz September 2010
    Posts: 7
    [quote="grungyparadigm"]I am using your plugin, and it is perfect for what I need it for! I am using it on my page http://www.grungyparadigm.com/poetry and the one thing I can't figure out is templates. I want to put a horizontal line in between each post that I filtered to the "poetry" page. Is this where I would use a template to add the horizontal line? I added the default category, renamed it "grungy.php" and directed the short code to it:

    "[catlist name=poems template=grungy numberposts=50 content=yes]"

    But I don't know how to change the code in the template to include the horizontal bar. Any suggestions?

    I am messing about with templates myself today, but can't get what I want done, so looked at yours for a break :)

    At the end of the template you will find something like this

    $lcp_output .='</li>';
    endforeach;
    $lcp_output .= '</ul>';
    ?>

    Change it, by adding <hr> to the first line:

    $lcp_output .='</li><hr>';
    endforeach;
    $lcp_output .= '</ul>';
    ?>

    That gave me a line between each item.

    This proves I am learning something, but I had better ask my own question now ;)
  • grungyparadigmgrungyparadigm September 2010
    Posts: 2
    Britzinoz! Thanks! I totally had the <hr> about 2 lines off of where it was supposed to go! Now that I see what you did, it makes perfect sense! MUCH appreciated!! YAY!

    [quote="Britzinoz"][quote="grungyparadigm"]I am using your plugin, and it is perfect for what I need it for! I am using it on my page http://www.grungyparadigm.com/poetry and the one thing I can't figure out is templates. I want to put a horizontal line in between each post that I filtered to the "poetry" page. Is this where I would use a template to add the horizontal line? I added the default category, renamed it "grungy.php" and directed the short code to it:

    "[catlist name=poems template=grungy numberposts=50 content=yes]"

    But I don't know how to change the code in the template to include the horizontal bar. Any suggestions?

    I am messing about with templates myself today, but can't get what I want done, so looked at yours for a break :)

    At the end of the template you will find something like this

    $lcp_output .='</li>';
    endforeach;
    $lcp_output .= '</ul>';
    ?>

    Change it, by adding <hr> to the first line:

    $lcp_output .='</li><hr>';
    endforeach;
    $lcp_output .= '</ul>';
    ?>

    That gave me a line between each item.

    This proves I am learning something, but I had better ask my own question now ;)
  • turistikusturistikus October 2010
    Posts: 1
    Hi,

    i wuld like to list post in 2 columns. How shuld i moderate template file to get 2 column listing?

    TNX

    PS: awesom plugin, at the moment im fighting with it:

    :sw1:
  • hostw3hostw3 October 2010
    Posts: 1
    I am also looking for how to make 2 or more columns for long list. Any help would be greatly appreciated.

    Thanks
  • tuttiprotuttipro October 2010
    Posts: 4
    Hi

    In my mind, this module very usefull (i've tested dozen of then before... without any succes exept this one !)
    Nice job fernando !

    i found a little bug ... wrong path for template

    replace line 83 (list_cat_posts.php)
    STYLESHEETPATH&#46;'/list-category-posts/'&#46;$atts&#91;'template'&#93;&#46;'&#46;php',
    with this
    WP_PLUGIN_DIR&#46;'/list-category-posts/templates/'&#46;$atts&#91;'template'&#93;&#46;'&#46;php',

    Fernando have you plan to add quickly the image ?
    Do you know this code ?
    function sc_postimage($atts, $content = null) {
    extract(shortcode_atts(array(
    &quot;size&quot; =&gt; 'thumbnail',
    &quot;float&quot; =&gt; 'none'
    ), $atts));
    $images =&amp; get_children( 'post_type=attachment&amp;post_mime_type=image&amp;post_parent=' &#46; get_the_id() );
    foreach( $images as $imageID =&gt; $imagePost )
    $fullimage = wp_get_attachment_image($imageID, $size, false);
    $imagedata = wp_get_attachment_image_src($imageID, $size, false);
    $width = ($imagedata&#91;1&#93;+2);
    $height = ($imagedata&#91;2&#93;+2);
    return '&lt;div class=&quot;postimage&quot; style=&quot;width&#58; '&#46;$width&#46;'px; height&#58; '&#46;$height&#46;'px; float&#58; '&#46;$float&#46;';&quot;&gt;'&#46;$fullimage&#46;'&lt;/div&gt;';
    }
    add_shortcode(&quot;postimage&quot;, &quot;sc_postimage&quot;);


    Is it possible to exclude the first post in the loop (the 5 last post exept the first (2,3,4,5) ??

    Regards

    Ludo
  • jhalseyjhalsey October 2010
    Posts: 2
    Fernando: I just started using your wonderful plugin and saw this posting where you say that you are considering simplifying like:
    <h3>[category title]</h3>
    <li>[post title] - [comments] [date] [author]</li>

    WOW! that would be incredible!!! I really encourage you to do that. Wow, that would be so cool.
  • prakashprakash November 2010
    Posts: 1
    I had sucessfully used your plugin. I had shown only 3 post of that category but I need a "View All" link at the buttom so that visitors can go to that category to view all the post.Please help me on this regards!!!
  • BluelalekBluelalek December 2010
    Posts: 4
    I ran into a problem trying to use your wonderful plugin. It occurs if I try to use templates (default.php copied into lists-category-posts inside my theme folder) and set the thumbnail parameter to YES (in order to display the thumbnail image). Then the page from which I'm trying to list the category returns the following error:

    ------------------
    The theme has encountered a problem that it cannot recover from. Please use the following information to try to resolve the problem.

    Error Code: php_code_error:1:/home/content/b/l/u/bluealek/html/wp-content/themes/BuilderChild-Foundation-Tropic/list-category-posts/default.php:53:Call to undefined function lcp_thumbnails()
    Message: A fatal code error occurred.
    -------------------

    How do I resolve this?
  • BluelalekBluelalek December 2010
    Posts: 4
    [quote="Bluelalek"]

    ------------------
    The theme has encountered a problem that it cannot recover from. Please use the following information to try to resolve the problem.

    Error Code: php_code_error:1:/home/content/b/l/u/bluealek/html/wp-content/themes/BuilderChild-Foundation-Tropic/list-category-posts/default.php:53:Call to undefined function lcp_thumbnails()
    Message: A fatal code error occurred.
    -------------------



    I resolved this one - default.php has a fault. In place of lcp_thumbnails($single) it shoud be lcp_thumbnail($single) . With this change everything works great.
  • sensicaldesignsensicaldesign February 2011
    Posts: 1
    Rodrigo, I'm having a template problem. I'm trying to wrap an h2 tag around the post title, using this code:

        //Show the title and link to the post:
        $lcp_display_output .= $this->get_post_title($single, 'h2');

    But I'm still just getting an <a> around the title. The other template changes I made (changing ul to div, for example) work. Thanks.
  • Project404Project404 March 2011
    Posts: 2
    Same problem. Having links instead of nice large titles isn't great and I dont seem to be able to change them to H2's. Did you have any luck sensicaldesign?
  • SATNUSATNU March 2011
    Posts: 2
    I wanna use a scrollbalk, how do i fix this?
  • fishermanfisherman March 2011
    Posts: 1
    Is there any way I can list one category from A to G on one page, and continue the rest of the list from H to Z on another page?
  • Maras13Maras13 March 2011
    Posts: 3
    Hi! Maybe someone can advise how to increase the font size category names and colors? I am new to programming, but I want to understand and learn. If someone would have the patience it is a step by step:) Thanks! Sorry for poor English language skills. If easy to write me an e-maille: marius.bagdonas67 @ gmail.com
  • Maras13Maras13 March 2011
    Posts: 3
    Hello. Can you help where to put the code on the theme Twenty Ten?

    .lcp_catlist { color: #0e8181; font-size: 12px; font-weight: 700; }

    .lcp_catlist li { list-style-type:none }
    Does the style.css or to another location?
    Thank you.
  • Project404Project404 April 2011
    Posts: 2
    Is there any support here at all??
  • kkrikkri April 2011
    Posts: 2

    I can't see the post thumbnail in the list page.


    [catlist id=fossombrone  thumbnails=yes excerpt=yes date=yes author=yes numberposts=-1]


    This is my shortcode inside the page (where the id "fossombrone" is a town). In the default.php Post Thumbnail section there is "$lcp_display_output .= $this->get_thumbnail($single);" so I think the code is right but the thumbnail doesn't appear. I'm using WP 3.1.


    Any idea? Thanks a lot, the plugin is so nice and useful.

  • CadoverCreativeCadoverCreative April 2011
    Posts: 1
    Hi,

    Great plugin. Apologies if you've already spotted this one, but there's a bug in version 0.18.3. The get_post_title method in CatListDisplayer.php doesn't call the assign_style function as the other functions in this class do.

    Cheers.
  • RicoRico July 2011
    Posts: 1
    This plug-in does a good job of displaying the author next posts in a category.

    I have a template going, and I can do some simple formatting to the text style, but I cannot figure out how to make the author displayed from this plug-in to actually link to that author's bio page dynamically.

    How do I pass that parameter into the display author line of the template so it will link to the author?
  • HQSecureHQSecure July 2011
    Posts: 1
    Project404 - No!

    I'm hacking away and had h2 tag success by adding to includes/CatListDisplayer.php around line 134:

        private function get_post_title($single, $tag = null, $css_class = null){
            return '<h2><a href="' . get_permalink($single->ID).'">' . $single->post_title . '</a></h2>';
        }

  • cookieandkatecookieandkate July 2011
    Posts: 1
    Hi, your plugin is fantastic. I used it to create a list of categories and their corresponding posts at http://cookieandkate.com/recipe-index/. However, I think I'd rather display my standard size thumbnails (135 x 135) instead of the post titles. I'd like the images to appear side by side in rows. I figured out how to turn on the thumbnails (changed no to yes), but the thumbnail images were displaying at full size, not 135 x 135. I couldn't for the life of me figure out how to specify the 135 x 135 images. I tried creating a custom template and editing the php files, but no luck. Any suggestions? I'd much appreciate your help!
  • GodoploidGodoploid August 2011
    Posts: 1
    I am having a very hard time figuring out the templates situation. I am using the Genesis Framework, I created custom widgets and then placed them into the proper templates but I am having a hard time figuring out how I can customize the output html in order to have the posts show the way I want. 

    The main thing I think I need to know is where to place this set of code:

    [catlist id=1 template=templatename] 

    Does this go in the template and where or is this something I add through Wordpresses backend? Any help would be greatly appreciated!!!
  • acfkevinacfkevin August 2011
    Posts: 2

    Anyone having issues with templates, pay close attention to Fernando's first post. Mira:



    Fernando said:

    Templates for the List Category Plugin are searched for in your WordPress theme's folder. You should create a folder named list-category-posts under wp-content/themes/your-theme-folder.



    The two places where the plugin looks for templates (the current theme's stylesheet and template paths) is defined on line 32 of include/CatListDisplayer.php of the most recent version (as of this writing). I too was fooled by this, and unfortunately the basic documentation for the plugin does not make mention of this fact. That the plugin .zip file unpacks with its own templates folder would lead you to believe that the templates go there, but they don't.

    If you want to prove to yourself the path for the template, modify CatListDisplayer.php (on a non-production site) starting at line 36 to look something like the following:



    foreach ($possibleTemplates as $key => $file) {
    echo "<h1>Checking: $file</h1>";
    if ( is_readable($file) ) {
    $tplFileName = $file;
    echo '<h2 style="color:green">'. $file . ' okay!</h2>';
    }
    }


    In my case, I created a template file called styledate.php in /my/sites/root/dir/wp-content/mythemename/list-category-posts, and everything worked as expected.

    I agree with Fernando that the template should go in your theme folder, probably your child theme folder if you're being diligent about keeping your local customizations separate from the "factory default" themes and plugins. It makes sense once you know that's where the plugin is looking for the templates.

    Fernando, do you think at some point in the future, por favor, you could clarify this on the documentation page, and in the readme.txt that comes with the plugin? I'll admit that readme.txt does give you some clues (like a link to this page), but it could be less confusing, especially around the **Usage** section.

    Godoploid: you put that "shortcode" directly in the post editor for a WordPress post or page wherever you want the category list to show up. The reason it's not doing anything for you right now is probably because you made the same mistake I did and put your template in the wrong place, which you can correct by following the advice above.




  • acfkevinacfkevin August 2011
    Posts: 2

    Hi, your plugin is fantastic. I used it to create a list of categories and their corresponding posts at http://cookieandkate.com/recipe-index/. However, I think I'd rather display my standard size thumbnails (135 x 135) instead of the post titles. I'd like the images to appear side by side in rows. I figured out how to turn on the thumbnails (changed no to yes), but the thumbnail images were displaying at full size, not 135 x 135. I couldn't for the life of me figure out how to specify the 135 x 135 images. I tried creating a custom template and editing the php files, but no luck. Any suggestions? I'd much appreciate your help!




    I'm guessing Category Thumbnail List was your solution. When you're using the plugin, be careful how you (and the author) spell "categoy" [sic], though. ;)

    This solution over at WordPress.org might have worked. It modifies the call to get_the_post_thumbnail in CatList.php to use a different image size. Haven't tested, but it looks like a hot ticket.
  • sheclimbersheclimber September 2011
    Posts: 1
    Hey there I am a beginner at all this and was wanting to use this plugin to create a listing on a page that looks exactly like the listing on the posts page - all the formatting, layout, etc - everything the same. I tried to start editing the template, but wasn't even successful in getting rid of the ul. Is it possible to copy and paste code from the template file that defines the posts page into a template file for this plugin to get the result I'm looking for? If so, could I have a few tips to point me in the right direction of how to do this? Thanks!
  • YetundeYetunde September 2011
    Posts: 1
    I need help with making my thumbs appear with pictures instead of the codes (see http://mydreamconnect.com/kna/?page_id=8).

    Thanks for your help

    Best Regards.
  • Tina_HTina_H October 2011
    Posts: 3
    Does anyone know how to move the thumbnail down a little bit? I'd also like the thumbnail to link to the same page as the link next to it - is this possible?
  • phew72phew72 October 2011
    Posts: 1
    HQSecure said:

    Project404 - No!

    I'm hacking away and had h2 tag success by adding to includes/CatListDisplayer.php around line 134:

        private function get_post_title($single, $tag = null, $css_class = null){
            return '<h2><a href="' . get_permalink($single->ID).'">' . $single->post_title . '</a></h2>';
        }



    I have a further fix for this problem. Try replacing the entire function with:

    private function get_post_title($single, $tag = null, $css_class = null){
        $info = '<a href="' . get_permalink($single->ID).'">' . $single->post_title . '</a>';
        return $this->assign_style($info, $tag, $css_class);
    }

    This seems to let your custom template wrap the title and apply a class, as it should.
  • bogotweetbogotweet October 2011
    Posts: 1
    I am new to WordPress and not a PHP coder, but I managed to get the template to work like WP normal posts by doing this (I was not able to get the template to add a tag and class as described in the comments)
    //$lcp_display_output .= '<ul>'; COMMENT OUT LINES WITH UL AND LI LIKE THIS

    foreach ($this->catlist->get_categories_posts() as $single):
    $lcp_display_output .= '<div class="post">';

        $lcp_display_output .= '<h2 class="title">';
        $lcp_display_output .= $this->get_post_title($single);
        $lcp_display_output .= '</h2>';
       $lcp_display_output .= $this->get_content($single);   
      
        //Close li tag
        $lcp_display_output .= '</div>';
        $lcp_display_output .= '</div>';
        $lcp_display_output .= '<div class="entry">';
    endforeach;
  • blossomingmindblossomingmind October 2011
    Posts: 1
    Has anyone had success adding a "click here to read more" underneath the excerpt?.....
  • NotoriousMKNotoriousMK October 2011
    Posts: 1
    How do I align the picture (thumbnail) on the left and the text next to it?

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