Support » Plugin: List category posts » How do I use custom templates?

  • Dustie


    I don’t understand how to edit custom templates and the instruction is not specific. It says to place template php file in the theme directory in “list-category-posts” subdirectory. That’s what I did. Now when I modify default.php, none of the changes take any effect.

    I’m using this shortcode inside a page:
    [catlist id=”7″ tags=”uslugi” template=”default.php”] and it just produces an unordered list with post titles of this category (7) and tag (uslugi).
    Even if I edit default.php and change ul to div and lcp_catlist to “I made this” like this:

    $lcp_display_output .= $this->open_outer_tag(‘div’, ‘i made this’);

    I still only get the default list with lcp_catlist class…

    Default.php file just seems to list all possible instructions? It’s not a template but some kind of reference? So how do I make a template that displays a post tile wrapped ina div with a custom class followed by post thumbnail wrapped in a div with a custom class?

    I really like this plugin so I’m hoping someone can explain templates to me…

    WordPress version: 5.5.1
    LCP version: 0.83.1

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor zymeth25


    The template shortcode parameter expects a template file name without the .php extension, so in your case template=default.

    Default.php file just seems to list all possible instructions?

    Yes, it is a template that includes all possible display options. But they only become active if you specify them in your shortcode. If you are sure you are not going to use certain options, e.g. author, you can remove them from your template.

    • This reply was modified 6 months ago by zymeth25.
    • This reply was modified 6 months ago by zymeth25.
    Thread Starter Dustie


    Thank you for your reply.
    I have this in my post/page:

    [catlist id="7" tags="uslugi" template=default]

    And this is my default.php file:

    global $post;
    while ( have_posts() ):
      // Check if protected post should be displayed
      if (!$this->check_show_protected($post)) continue;
    $lcp_display_output .= '<div class="list-post-title">';
    $lcp_display_output .= $this->get_post_title($post, 'div', 'imadethis'); 
    $lcp_display_output .= '</div>';

    Still there is no change to anything, the html output is still the original one, with ul/li, lcp_catlist class, etc.

    What am I doing wrong?

    Plugin Contributor zymeth25


    Let’s try to summarise:

    1. You created a subdirectory for custom templates in your active theme’s directory, e.g. for Twenty Twenty-One that would be wp-content/themes/twentytwentyone/list-category-posts/.
    2. You placed deafult.php in that subdirectory.
    3. You tried the shortcode [catlist id="7" tags="uslugi" template=default] and it ignored the template

    Is this correct?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.