WordPress.org

Ready to get started?Download WordPress

Forums

WP-PostViews
[resolved] Using Custom Fields for Thumbnail (17 posts)

  1. halluzineyt
    Member
    Posted 3 years ago #

    http://tntbase.com/worpress-help/add-thumbnails-to-the-wp-postviews-plugin/

    this is used for the first image on your post but Is there any way to use custom fields for thumbnails?

    http://wordpress.org/extend/plugins/wp-postviews/

  2. Dutch SilverShadow
    Member
    Posted 3 years ago #

    I want to know this too!!! I now make custom wp_queries but is it possible to add the custom field "thumnail" as well?

    Greetz

  3. halluzineyt
    Member
    Posted 3 years ago #

    Youre a one lucky guy for replying in my thread..

    <?php query_posts('r_sortby=most_rated&r_orderby=DESC&showposts=6&cat=28') ?>
    <?php while (have_posts()) : the_post(); ?>

    " title="<?php the_title(); ?>"><img src="<?php echo get_post_meta($post->ID, "Your Custom Field", true); ?>" width="180" height="119" alt="<?php the_title(); ?>" />

    You could view it here at my site.
    e http://www.flippish.com/

    , Now i have a request for you if ever you knew how can i play embeded wordpress videos on facebook please post the instructions on a thread. That will be a big help to me. Thanks

  4. halluzineyt
    Member
    Posted 3 years ago #

    <?php query_posts('r_sortby=most_rated&r_orderby=DESC&showposts=6&cat=28') ?>
    <?php while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><img src="<?php echo get_post_meta($post->ID, "bigthumb", true); ?>" width="180" height="119" alt="<?php the_title(); ?>" />
    </a>
  5. Dutch SilverShadow
    Member
    Posted 3 years ago #

    That aint the right code. This is just a querypost, on top of it all there is no most_rated column... I just get the newest posts sorted... Please provide me with the right code...

  6. halluzineyt
    Member
    Posted 3 years ago #

    go to the wp_postviews directory and edit wp_postviews.php

    find this line

    $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars);
    $temp = stripslashes($views_options['most_viewed_template']);
    $temp = str_replace("%VIEW_COUNT%", number_format_i18n($post_views), $temp);
    $temp = str_replace("%POST_TITLE%", $post_title, $temp);
    $temp = str_replace("%POST_EXCERPT%", $post_excerpt, $temp);
    $temp = str_replace("%POST_CONTENT%", $post->post_content, $temp);
    $temp = str_replace("%POST_URL%", get_permalink($post), $temp);
    $output .= $temp;

    Change to this

    $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars);
    $post_content = get_the_content();
    $thumbnail = get_post_meta($post->ID,"bigthumb",true);
    $temp = stripslashes($views_options['most_viewed_template']);
    $temp = str_replace("%VIEW_COUNT%", number_format_i18n($post_views), $temp);
    $temp = str_replace("%POST_TITLE%", $post_title, $temp);
    $temp = str_replace("%POST_EXCERPT%", $post_excerpt, $temp);
    $temp = str_replace("%POST_CONTENT%", $post->post_content, $temp);
    $temp = str_replace("%POST_URL%", get_permalink($post), $temp);
    $temp = str_replace("%THUMBNAIL%", $thumbnail, $temp);
    $output .= $temp;

    after that you can add %THUMBNAIL% on your postviews templates

    example

    <img src="%THUMBNAIL%" alt="" width ="180" height="115"/>

    Note: do this on### Function: Display Most Viewed Page/Post you can do this also on the other functions.

    got it?

  7. Dutch SilverShadow
    Member
    Posted 3 years ago #

    halluzineyt,

    Thanks for your comment, but I just fixed it yesterday exactly the same way as you explained it in your comment ;).

    `$post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars);
    $temp = stripslashes($views_options['most_viewed_template']);
    $temp = str_replace("%VIEW_COUNT%", number_format_i18n($post_views), $temp);
    $temp = str_replace("%POST_TITLE%", $post_title, $temp);
    $temp = str_replace("%POST_EXCERPT%", $post_excerpt, $temp);
    $temp = str_replace("%POST_CONTENT%", $post->post_content, $temp);
    $temp = str_replace("%POST_URL%", get_permalink($post), $temp);
    /*
    I've added a custom field for the thumbnail ;)
    */
    $temp = str_replace("%POST_THUMB%", get_post_meta($post->ID, 'thumb', true), $temp);
    $output .= $temp;

    You can view it in my website here, http://docunet.nl, at the "Top 5 best bekeken docu's"...

    I also have the plugin related-posts installed, this plugin doesn't show any thumbs-via-custom-fields by default, so I edited the theme and as you can see on http://docunet.nl/commando-on-the-front-line/ in the sidebar there is a column called "Gerelateerde Documentaires", en voila my related posts also with a custom-field-thumb.

    If someone wants to know how I did the custom-field-thumb on related-posts-plugin just shout...

    Thanks guys!

  8. PoMa
    Member
    Posted 2 years ago #

    Dutch SilverShadow, thanks! Your example was good.

    Everyone:
    in this line:
    $temp = str_replace("%POST_THUMB%", get_post_meta($post->ID, 'thumb', true), $temp);

    ir you will change "thumb" to any other custom field name, you will get what you want.

    For most viewed posts lines are around 240, 250 in wp-postviews.php

    And the last one - do not forget to add html img tags to your most viewed posts in postviews admin panel.

    GL HF

  9. wblake37
    Member
    Posted 2 years ago #

    I hope i'm not too late to ask for some help.

    I followed halluzineyt example and when it comes to displaying the thumbnails instead of it grabbing them, it thinks the url for the image is

    http://examplewebsite.com/category/featured/%POST_THUMB%

    it doesnt seem to go right into the post and grab the jpg thats held inside the custom field "thumb"

    any ideas?

    Thanks

  10. wblake37
    Member
    Posted 2 years ago #

    awesome got it!

    $temp = str_replace("%POST_THUMB%", get_post_meta($post->ID, 'thumb', true), $temp);

    not sure what i done wrong!

  11. bendol
    Member
    Posted 2 years ago #

    dont work for me...

    can someone tell me how to this plugin work with thumbnail ??

    and which version you are using..??

    pls help...

  12. Dutch SilverShadow
    Member
    Posted 2 years ago #

    @Bendol:
    What is your problem exactly???

  13. bendol
    Member
    Posted 2 years ago #

    I want to add thumbnails in this plugin...just like in ur blog...

    and i dunno how to do it so maybe u can help...(my english is really bad "sorry for that") i run wordpress on the local (xampp)..

    and if u have free time pls help

    YM : bendol_online@yahoo.com

    using TeamViewer will probably be much easier for you :D

    anyway thanks for replying

  14. Dutch SilverShadow
    Member
    Posted 2 years ago #

    @bendol:
    Ok, you've got the plugin installed, aight? Have you found the wp-postviews.php in root/wp-content/plugins/wp-postviews/wp-postviews.php ????

    If you have, open wp-postviews.php so you can edit it. Then the question is, what type of function do you use to obtain your goal? Or better what do you want wp-postviews to do in your blog (show the least postviews/show the most postviews)?

    So if you decided what you want from your wp-postviews plugin find the line that correspondents with the right function. You can also add the requested line in all of the functions... I've made a list of the line numers (app.)...
    Do you want to ### Function: Display Least Viewed Page/Post -----> line 171
    Do you want to ### Function: Display Most Viewed Page/Post -----> line 213
    Do you want to ### Function: Display Leased Viewed Page/Post By Category ID -> line 262
    Do you want to ### Function: Display Most Viewed Page/Post By Category ID -> line 309
    Do you want to ### Function: Display Most Viewed Page/Post By Tag ID -> line 356
    Do you want to ### Function: Display Least Viewed Page/Post By Tag ID -> line 403
    --------------
    NOW PAY ATTENTION!!!!
    In every function you'll find two lines like this:
    $temp = str_replace("%POST_URL%", get_permalink($post), $temp);
    $output .= $temp;

    Paste this between the first and the second line above:
    $temp = str_replace("%POST_THUMB%", get_post_meta($post->ID, 'thumb', true), $temp);

    IMPORTANT!
    Where you see 'thumb', this is the variable of your custom field so if you custom field variable is dickhead the line will become:
    $temp = str_replace("%POST_THUMB%", get_post_meta($post->ID, 'dickhead', true), $temp);

  15. bendol
    Member
    Posted 2 years ago #

    still i dont get it...pls check the picture below and tell me whats wrong

    http://photobucket.com/imageswp

    thank you

  16. Dutch SilverShadow
    Member
    Posted 2 years ago #

    @Bendol:
    Such an ass! You never said you were using the featured image option. I was talking about custom fields. These are very different!!!

    This line is to be used when using custom fields:
    $temp = str_replace("%POST_THUMB%", get_post_meta($post->ID, 'thumb', true), $temp);

    I think this line is to be used when using the featured image option:
    $temp = str_replace("%POST_THUMB%", get_the_post_thumbnail($page->ID, 'thumbnail'), $temp);

    LET ME NO IF IT WORKS!!!!!

  17. Geost
    Member
    Posted 2 years ago #

    Hi Dutch SilverShadow!
    Hope you can help me, this is my site: http://atrum-blog.com/
    I'am using the featured image option, I activated the thumbnail support for the theme on "functions.php" and I used the code you suggested to "bendol".

    It's not working for me, do I need to edit "most_viewed_template"???

    Regards

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic