WordPress.org

Ready to get started?Download WordPress

Forums

WP Favorite Posts
Favorite page view: thumbnails in table (7 posts)

  1. tomlat
    Member
    Posted 2 years ago #

    Hello,

    I have successfully used this code:

    echo "<ul>";
        if ($favorite_post_ids):
    		$favorite_post_ids = array_reverse($favorite_post_ids);
            foreach ($favorite_post_ids as $post_id) {
    
    			$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, 'thumbnail' );
    						echo "</a>";
    						echo "</div></div>";
    
                echo "<li>";
                echo "<a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a> ";
                wpfp_remove_favorite_link($post_id);
                echo "</li>";
            }
        else:
            echo "<li>";
            echo $wpfp_options['favorites_empty'];
            echo "</li>";
        endif;
        echo "</ul>";

    to display post thumbnails along with permalinks.

    My question is: how can I arrange them in a table (4 columns) instead of a

    • list.

      Please help...

      Thanks

    http://wordpress.org/extend/plugins/wp-favorite-posts/

  2. www.n1bar.com
    Member
    Posted 2 years ago #

    I did the following but is kinda buggy, when you remove a bookmark it doesnt really remove it unless you refresh, it has something to do with the tables.

    if ($favorite_post_ids):
    		$favorite_post_ids = array_reverse($favorite_post_ids);
    echo "<table id=\"fav-table\" width=\"100%\">\n";
            foreach ($favorite_post_ids as $post_id) {
                $p = get_post($post_id);
    			echo "<tr>\n";
    			echo "<td>" . get_the_post_thumbnail($post_id, array(55,55), array('class' => 'fav-thumbs')) . "</td>\n";
    			echo "<td><a href='".get_permalink($post_id)."' title='". $p->post_title ."'><span class='fav-title'>" . $p->post_title . "</span></a></td>\n";
    			echo "<td>";
    			wpfp_remove_favorite_link($post_id);
    			echo "</td>\n";
    			echo "</tr>\n";
            }
    		echo "</table>\n";

    Also i got rid of all the

      and
    • tags
  3. www.n1bar.com
    Member
    Posted 2 years ago #

    LI and UL tags got removed,

  4. solveigm
    Member
    Posted 1 year ago #

    Sorry for being a novice, but where excactly do I paste this?

  5. glamgirlsale
    Member
    Posted 1 year ago #

    Hi solveigm,

    It goes in the wpfp-page-template.php file. You will see a similar code already there, just replace it with one of the codes above. I personally could not get the second code to work; keeps throwing parsing errors. But maybe it will work for you.

    good luck!

  6. sydneycraig
    Member
    Posted 1 year ago #

    thanks, the 1st code works great, but on a full width page doesnt loook good...

    the second works too, but as mentioned when you delete an item from the table it stays there until you refresh which also looks a bit crappy!

    any other solutions to this one??

  7. ksaffy
    Member
    Posted 1 year ago #

    Use a list format instead of a table (a list is a million times better than table esp for mobile devices).

    CSS for UL:

    #favorite_thumbnails{list-style-type:none;list-style-position:inside;padding:0;margin:0}
    #favorite_thumbnails li{float:left;margin:0;padding-left:7px;padding-right:7px;padding-top:2px;padding-bottom: 2px;display:block;opacity:1}
    #favorite_thumbnails li a{border:0 none;line-height:normal;font-size-adjust:none;font-stretch:normal;clear:right}
    #favorite_thumbnails li a+a{position:relative;top:-50px;display:block;padding-left:10px;padding-top:5px;padding-bottom:0;padding-right:0;margin-left:0;width:auto;height:auto;background:#000!important;overflow:hidden;height:40px;color:#FFF!important;text-decoration:none;font:12px Arial;text-transform:uppercase;font-weight:800;opacity:.8}
    #favorite_thumbnails img{padding:2px;margin:0;border:0 none}
    #favorite_thumbnails img:hover{opacity:.3;transition:opacity .5s linear}

    CODE:
    Use this code for the if statement.

    if ($favorite_post_ids):
         $favorite_post_ids = array_reverse($favorite_post_ids);
    
            foreach ($favorite_post_ids as $post_id) {
                $p = get_post($post_id);
                $l = get_permalink($post_id);  
    
                echo "<ul id='favorite_thumbnails'><li>";
    
    echo "<a href='".get_permalink($post_id)."'>";
    echo get_the_post_thumbnail ( $post_id, 'thumbnail' );
    echo "<br>";
    echo "<span><a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a></span>";
    wpfp_remove_favorite_link($post_id);
    
                      echo "</li></ul>";
                    echo "</a>";

    I close the list here as the else statement in my code doesn't have a list format.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.