0

For the life of me I can't get a clean answer to my issue. The codex says to use get thumbnail but whenever I exchange the current code for the get thumbnail everything just stops working. I'm fairly new to php and this is my first big project suggestions?

Here's the whole code I'm working with

<?php
$wpfp_before = "";
echo "<div class='wpfp-span'>";
if (!empty($user)) {
    if (wpfp_is_user_favlist_public($user)) {
        $wpfp_before = "$user's Favorite Posts.";
    } else {
        $wpfp_before = "$user's list is not public.";
    }
}

if ($wpfp_before):
    echo '<div class="wpfp-page-before">'.$wpfp_before.'</div>';
endif;

if ($favorite_post_ids) {
    $favorite_post_ids = array_reverse($favorite_post_ids);
    $post_per_page = wpfp_get_option("post_per_page");
    $page = intval(get_query_var('paged'));

    $qry = array('post__in' => $favorite_post_ids, 'posts_per_page'=> $post_per_page, 'orderby' => 'post__in', 'paged' => $page);
    // custom post type support can easily be added with a line of code like below.
    // $qry['post_type'] = array('post','page');
    query_posts($qry);

    echo "<div>";
    while ( have_posts() ) : the_post();
        echo "<div><a href='".get_permalink()."' title='". get_the_title() ."'>" . get_the_title() . "</a> " ;
        wpfp_remove_favorite_link(get_the_ID())  . the_post_thumbnail('medium' );
        echo "</div>";
    endwhile;
    echo "</div>";

    echo '<div class="navigation">';
        if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
        <div class="alignleft"><?php next_posts_link( __( '&larr; Previous Entries', 'buddypress' ) ) ?></div>
        <div class="alignright"><?php previous_posts_link( __( 'Next Entries &rarr;', 'buddypress' ) ) ?></div>
        <?php }
    echo '</div>';

    wp_reset_query();
} else {
    $wpfp_options = wpfp_get_options();
    echo "<ul><li>";
    echo $wpfp_options['favorites_empty'];
    echo "</li></ul>";
}

echo '<p>'.wpfp_clear_list_link().'</p>';
echo "</div>";
wpfp_cookie_warning();

During the_post_thumbnail('medium') it works once I change it to the get_the_post_thumbnail everything falls apart. I've tried adding the src and I have also added the following code wordpress told me to add to the functions section.

add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );

function my_post_image_html( $html, $post_id, $post_image_id ) {
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>';
return $html;
}
2

1 Answer 1

0

After spending 8 hours banging my head I had to do some investigating into the internet. Figured out some stuff and got it to work. Apparently I'm the only one who's had this issue so I'm going to post my answer to help fellow Web Programmers.

So above you will see my original code, I am using the WP Favorite Posts to get the posts that the user favorites but it doesn't come with image support so I add images and then the linking issue occurred. My solution was the following code below but despite it being this code, I couldn't find any info about this on the codex.

Anywho here's the code part I changed I hope it helps! Simply look on top an see what I changed/added.

echo "<div>";
while ( have_posts() ) : the_post();
echo "<div><a href='".get_permalink()."' title='". get_the_title() ."'>" . 
get_the_title() . "</a> " ;
wpfp_remove_favorite_link(get_the_ID());
echo '<a href="' . get_permalink($post->ID) . '" >';
the_post_thumbnail('medium');
echo '</a>';
echo "</div>";
endwhile;
echo "</div>";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.