WordPress.org

Support

Support » Plugins and Hacks » [Plugin: WP Favorite Posts] Can I sjow Images?

[Plugin: WP Favorite Posts] Can I sjow Images?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Dave Wright
    Member

    @davetwizzlebird

    Hi, I’m trying to do this also, perfect plugin if only I could figure out how to display post_thumbnails.

    Stefan
    Member

    @istefan

    Hi

    Anyone worked out how to do this?

    Dave Wright
    Member

    @davetwizzlebird

    Hi, I amended the plugin to acheive this,
    try the following in your wpfp-page-template.php

    $p = get_post($post_id);
    			echo "<div class='post'><div class='entry'>";
    			echo "<a href='".get_permalink($post_id)."'>";
    			echo get_the_post_thumbnail ( $post_id );
    			echo "</a>";
    			echo "</div></div>";

    I can’t remember what was there before but it should be pretty easy to find the snippet.
    Hope this helps

    Stefan
    Member

    @istefan

    Thanks Dave

    All makes sense. I tried it but it’s not displaying the thumbnails. Check the HTML and there’s nothing in there either.

    Any thoughts?

    Ideally I’d like the large image associated with the post to be dispalyed – I’m trying to build a favourites page for a photo gallery.

    Cheers

    Stefan

    Stefan
    Member

    @istefan

    Anyone else know how to add a post image to the favorites list?

    Any help much appreciated.

    Thanks Dave for good hint.
    But I need modify that code little more… Can some1 help?

    $p = get_post($post_id);
          echo get_template_part( 'templates/post/post-header' );
          echo "<div class='postContent'>";
          echo "<a href='".get_permalink($post_id)."'>";
    			echo get_the_post_thumbnail( $post_id );
    			echo "<br>";
    			echo "<a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a> ";

    – I made this, BUT… It takes name of page (favorite posts) to header of each post, but I need post id… Is there any possibility to make it?
    – I need to get the thumbnail smaller like 150×150 px. How Can I?
    Pls help. Thank you!

    Dave Wright
    Member

    @davetwizzlebird

    Hi, untested but try…

    $p = get_post($post_id);
          echo the_id();
          echo "<div class='postContent'>";
          echo "<a href='".get_permalink($post_id)."'>";
    			echo get_the_post_thumbnail( $post_id,'smallthumb' );
    			echo "<br>";
    			echo "<a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a> ";

    Here I’ve changed the “get template part” line to echo the ID and added the argument “smallthumb” to the thumbnail. Your code should now look for the smallthumb sized thumbnail.

    The next step is to create this thumbnail size by adding the following into your functions.php

    add_image_size( 'smallthumb', 150, 150);

    So from now on all new images you upload will automatically have a 150×150 pixel version you can call up.

    Finally you may have to re-build your old thumbnails, this is to make sure images you have previously uploaded have a smallthumb (150×150) version you can call upon. If you search the plugin repository for thumbnail rebuild or similar you’ll find there are a few tools for the job.

    Let us know how you get on

    Thank you very much ๐Ÿ™‚ thumbnail works perfectly but…
    this echo the_id(); says just 20 on my page (???)

    And I made new template part post-header-favorites and there is a code <h2 class="postTitle"><a href="<?php the_permalink($post_id) ?>" title="<?php _e('Permalink to', 'Arjuna'); ?> <?php the_title(); ?>"><span><?php the_title(); ?></span></a></h2> for getting Title, but this code takes title from page “favorite posts” so every favorite post on this page have Title in this template part “favorite post” :D. Can I somehow change it for post title?

    Thanks for any helps and hints ๐Ÿ™‚

    Dave Wright
    Member

    @davetwizzlebird

    hi, echo the_id will always give you the numeric ID for a post, thought thats what you wanted, try changing
    echo the_id();
    to
    echo the_title();

    again favorite post…

    btw.
    <a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a> works here and its normal link to post but I need get this “function” to this code->
    <h2 class="postTitle"><a href="<?php the_permalink($post_id) ?>" title="<?php _e('Permalink to', 'Arjuna'); ?> <?php the_title(); ?>"><span><?php the_title(); ?></span></a></h2> bcs its a link for each post

    Hi Dave,
    another vision ๐Ÿ˜€
    Can i get this thumbnails with titles to 3 columns? I mean like pexeso view :D…

    learner24
    Member

    @learner24

    someone please help,
    when I put echo get_the_post_thumbnail ( $post_id );
    in wpfp-page-template.php,
    I get Fatal error: Call to undefined function get_the_post_thumbnail()
    please help, thanks.

    learner24
    Member

    @learner24

    hey duskio,
    Did you change any thing else accept wpfp-page-template.php ??
    I am asking because the code: `$p = get_post($post_id);
    echo the_id();
    echo “<div class=’posts’>”;
    echo “<a href='”.get_permalink($post_id).”‘>”;
    echo get_the_post_thumbnail( $post_id );
    echo “<br>”;
    echo “<a href='”.get_permalink($post_id).”‘ title='”. $p->post_title .”‘>” . $p->post_title . “</a> “;`

    is not working from me, it gives me Fatal error: Call to undefined function get_the_post_thumbnail()

    I am using the wordpress 3.2

    please help…

    no i didnยดt maybe u dont have this add_theme_support( 'post-thumbnails' ); in your function.php?

    havenner
    Member

    @havenner

    Okay, I got a few of these requests to work. The trick was to break up all of the php echos on the wpfp-page-template.php so you can add styling in between commands. In my example, I separated the image and the excerpt of the favoritepost into a table and positioned the title of the post above the image.

    Here’s how it looks: (Note that the post excerpt is called using added code in WordPress’ function.php file found here — need to add this code in order to call the post excerpt when it is outside of the loop):

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Plugin: WP Favorite Posts] Can I sjow Images?’ is closed to new replies.