[Plugin: WordPress Popular Posts] Make whole <li> clickable
-
Instead of having just the image and title clickable, is it possible to turn the whole
- into a link for the permalink?
-
Unfortunately, that cannot be done at the moment without hacking my plugin’s source code. WPP does not offer that much flexibility yet so if you want to achieve that you’ll have to get your hands dirty with code.
I can guide you with that, however chances are that you’ll have to apply this every time WordPress Popular Posts is updated to a newer version.
I don’t mind if that’s ok with you.
I have to update the timthumb.php file at each update anyway
Alright then, please follow these instructions:
- Open
wordpress-popular-posts.phpusing your favorite editor such as Notepad or Adobe Dreamweaver. - Around line 650, change
$thumb = "<a href=\"".get_permalink($wppost->ID)."\" title=\"". htmlspecialchars($title_attr) ."\"><img src=\"". $this->pluginDir . "/scripts/timthumb.php?src=". $img[1] ."&h=".$instance['thumbnail']['height']."&w=".$instance['thumbnail']['width']."&zc=1\" alt=\"".$wppost->post_title."\" border=\"0\" class=\"wpp-thumbnail\" width=\"".$instance['thumbnail']['width']."\" height=\"".$instance['thumbnail']['height']."\" "."/></a>";into
$thumb = "<img src=\"". $this->pluginDir . "/scripts/timthumb.php?src=". $img[1] ."&h=".$instance['thumbnail']['height']."&w=".$instance['thumbnail']['width']."&zc=1\" alt=\"".$wppost->post_title."\" border=\"0\" class=\"wpp-thumbnail\" width=\"".$instance['thumbnail']['width']."\" height=\"".$instance['thumbnail']['height']."\" "."/>"; - Around line 678, change
$content .= '<li>'. $thumb .'<a href="'. get_permalink($wppost->ID) .'" title="'. htmlspecialchars($title_attr) .'">'. htmlspecialchars_decode($post_title) .'</a>'. $post_content .' '. $stats . $rating .'</li>' . "\n";into
$content .= '<li><a href="'. get_permalink($wppost->ID) .'" title="'. htmlspecialchars($title_attr) .'">'. $thumb .' '. htmlspecialchars_decode($post_title) .' '. $post_content .' '. $stats . $rating .'</a></li>' . "\n"; - Save changes and close the file.
- You might also need to change your theme’s style to make the whole li clickable by setting the a tag’s display property style to
block. Not too sure about this step, though.
Please note that I haven’t tested this so if you encounter any errors please let me know.
P.S.: why do you update the timthumb.php file each time? Got any problems with it?
Sorry Ikki24, I was away for a couple of days and couldn’t reply.
I’ve tried the changes that you have suggested with
display:block. The thumbnail link is removed, but it doesn’t make the whole li clickable.
The 3. change for line 678 doesn’t affect how your plugin displays. I’ve tried to remove the line to see if it affects it in any way, but it doesn’t.
Are there any changes that need to be done to line 675? I see an<a>and$thumb, but have no idea how that works.About timthumb.php, I need to make the changes because of my previous problem
Are you using the custom HTML feature?
Yes, I’ve removed the unnecessary bits. It works now. Thank you so much for the help
- Open
The topic ‘[Plugin: WordPress Popular Posts] Make whole <li> clickable’ is closed to new replies.