Support » Plugin: Page2cat: Category, Pages & Posts Shortcodes » [Plugin: Category Page] Want to display a thumbnail with catlist tag

  • Resolved TheDailyDG

    (@thedailydg)


    Hi all, I’m using the “catlist” tag in the Category Page plugin to display pages with post excerpts, as in: http://es.diegograglia.net/horahispana/
    I want to display a thumbnail for each post. I have activated thumbnails in functions.php and assigned a “featured image” to the posts.
    Now I don’t know how to write the php to have catlist call it. Would this be correct? (I only added the line in bold.)

    foreach($catposts as $single):
    $output .= “<h3>ID).”‘>”.$single->post_title.”</h3>”;
    $output .= “$single->post_excerpt”;
    $output .= “$single->the_post_thumbnail()”;

    endforeach;

    Thanks for any help!

Viewing 11 replies - 1 through 11 (of 11 total)
  • It’d be better to put it into it’s own variable instead. While it makes the code longer, if something changes in wp or something you have the benefit of changing only one thing:

    $the_thumbnail = get_the_post_thumbnail($single->ID, 'thumbnail');
    $output .= $the_thumbnail

    I just added this functionality in though. You can check it out here.

    Thread Starter TheDailyDG

    (@thedailydg)

    I used the whole code you posted in the other thread and it works like a charm: http://es.diegograglia.net/horahispana/
    I just need to style it a bit and it’ll be perfect.
    Thank you very very much, Pneumonic.

    Thread Starter TheDailyDG

    (@thedailydg)

    I just realized one thing though: it doesn’t use the manual excerpt but the first 500 words from the actual post. How can I change that?
    Thanks a bunch.

    Thread Starter TheDailyDG

    (@thedailydg)

    Ok, I figured this out by myself! So here it is for anyone as ignorant as myself.

    [For me, PHP is like being in a foreign country where I’m using a phrase book to find the bus terminal. Don’t know the language but I usually, slowly, get there.]

    My theme had a conflict with the neat_trim function, so I had to delete that for the plugin to work.

    Here’s what I wrote –you’ll tell me how unorthodox it is– to have the thumbnail AND the manually-written post excerpt in the page that displays a category’s posts.

    All I had to do was change the $single_post_content line to this:

    foreach($catposts as $single): $single_post_content = $single->post_excerpt;

    … where post_excerpt replaces post_content.

    Again, big thanks to Pneumonic for helping out.

    Pneumonic

    (@pneumonic)

    Damn wordpress not notifying me of replies again…

    Anyhow. Yeah that’s spot on how I’d go about doing it though (without actually looking at my hacked-ass code :). Glad I was able to help.

    Hey All,

    I’ve tried everything here and I’m getting the feature image of the page as a thumbnail in my list, not the featured image of the post.

    Thanks,

    Thread Starter TheDailyDG

    (@thedailydg)

    Hi Marcus, maybe you’re using the wrong category ID?
    I did this three months ago and honestly don’t remember exactly how it worked, but it could help if you publish a link.

    I have the right category ID. I’m now just getting the list of posts and not the post thumbnail.

    http://vangi-art.com/animals/

    at what line does the code need to go?

    OK, so here’s my new dilemma 😛

    I can get just a thumbnail with excerpt and I select “Yes” for the thumbnail, or I can get the full post. If I set the number of characters (I’m assuming it’s characters) from 500 to 0, I still get the full excerpt. If I deselect excerpt and select yes for thumbnails, I only get a title.

    Thanks again.

    Thread Starter TheDailyDG

    (@thedailydg)

    Well, your problem seems to be the same I had. And that’s where that altered line of code came in:

    “All I had to do was change the $single_post_content line to this:

    foreach($catposts as $single): $single_post_content = $single->post_excerpt;

    … where post_excerpt replaces post_content.”

    That did it for me. Hope it works.

    Yay it works! Thanks for your help.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: Category Page] Want to display a thumbnail with catlist tag’ is closed to new replies.