List category posts
morelink heads to a wrong url (6 posts)

  1. alby54
    Posted 3 years ago #

    While the excerpt title links to the correct post...
    the 'read more...' is pointing to a category folder that does not exist
    and then it's adding the category name

    my shortcode in the news page is
    [catlist name=news numberposts=-1 content=no excerpt=yes excerpt_size=255 morelink="Continue reading..." morelink_class="continue" orderby=date order=DSC]

    Can't figure out whatìs wrong..... any clue?



  2. alby54
    Posted 3 years ago #

    OK, I might have misunderstood the purpose of the "morelink" shortcode, anyway, what I was after was the possibility of adding a "continue reading..." link at the bottom of the excerpt that could link to the full version of the post. The way the plugin is set, morelink links like this:
    ....../category/the category name. The way the link is set, is implemented into CatListDisplayer.php as follows:

    //Close wrapper tag
    		$this->lcp_output .= '</' . $tag . '>';
    		if (!empty($this->params['morelink'])):
    			$href = 'href="' . get_category_link($this->catlist->get_category_id()) . '"';

    I personally think there's not much of a clever use for this feature so I changed the code to my needs:

    $this->lcp_output .= '</' . $tag . '>';
    		if (!empty($this->params['morelink'])):
    			$href = 'href="' . get_permalink($single->ID) . '"';
    		$class = "";
    		if (!empty($this->params['morelink_class'])):
    			$class = 'class="' . $this->params['morelink_class'] . '" ';
    		$readmore = $this->params['morelink'];
    		$this->lcp_output .= '<a ' . $href . ' ' . $class . ' >' . $readmore . '</a>';

    This way when I hit the "continue reading" link I get to the article and not to a category page which doesn't even exist.

  3. fernandobt
    Plugin Author

    Posted 3 years ago #

    I might add something like this to the plugin, but the post's title links to the post itself. Still, I can add it as a parameter in case you want a "read more" link for each post.

  4. alby54
    Posted 3 years ago #

    Yes the title links to the relative post. When I wrote the previous msg I didn't check the script with more than one post and I didn't realize that it wouldn't have worked that way. I, anyway, managed to get what I was after.. by adding a template file in my child folder/ list-category-posts/customlist.php
    In the customlist.php I added as follows:

    $lcp_display_output = '';
    $lcp_display_output .= '<ul class="lcp_catlist">';
    foreach ($this->catlist->get_categories_posts() as $single):
    $lcp_display_output .= '<li>';
    $lcp_display_output .= $this->get_post_title($single);
    $lcp_display_output .= $this->get_thumbnail($single);
    $lcp_display_output .= $this->get_excerpt($single, 'p', 'your p style');
    $lcp_display_output .= '<a class="continua" href="'.get_permalink($single->ID).'"><em>Continua a leggere...</em></a>';
    $lcp_display_output .= '</li>';
    $lcp_display_output .= '</ul>';
    $this->lcp_output = $lcp_display_output;

    without the closing php code. So I was able to get a link to every single post and got some extra styling also.
    I added the template=customlist" into the shortcode and that did it.
    I still think that if you will provide an option like this directly from the shortcode.. it would be very nice.
    Thx a lot for your kind answer and for the great plugin.

  5. zahinwadud
    Posted 3 years ago #

    Thank you alby54 for your code. I was looking for it.
    Just a curious ques, how can i style it. I saw the 'class' attributes but didn't understand how to implement. How can i show the title in a bigger font or in a different color. Thanks in advance.

    Edit: should i add the class In the style.css for my theme ?

  6. alby54
    Posted 3 years ago #

    You can modify the code and create a class for the title
    $lcp_display_output .= '<h2 class="entry-title">' . $this->get_post_title($single) . '</h2>';
    In this example you will need to style h2.entry-title with the attributes you want and that's something you can add into your theme css sheet. Same thing can be done with paragraph, thumbnail and "more..."

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • List category posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.