Are you looking for a way to control the custom display of links? While there’s probably a plugin for this, we have created a quick code snippet that you can use to control the custom display on links in WordPress.
This should probably go into a separate page template but should basically work anywhere in your theme. You can gain total control over the way your theme displays your links / bookmarks / blogroll.
Instructions:
All you have to do is add this code to your theme’s single.php file or in a site-specific plugin:
<?php //get links from database (works outside of loop) $links = $wpdb->get_results("SELECT * FROM $wpdb->links ORDER BY link_name ASC"); //start the table echo "<table border='0' class='linktable'>"; //start going through all the links and get the required values for each link foreach ($links as $link) { $linkurl=$link->link_url; $linkdesc=$link->link_description; $linkname=$link->link_name; $linkimage=$link->link_image; $linknotes=$link->link_notes; //write a table row for each link with the link image in the left cell and name and description in right cell echo "<tr><td><a href='$linkurl' target='_blank'><img src='$linkimage' alt='$linkurl' border='0' class='linkimg'></a></td>"; echo "<td valign='top' class='link-desc'><h5>$linkname</h5>"; echo "<div class='link-description'>$linkdesc </div></td></tr>"; } //finish going through all the links echo "</table>"; //close the table ?>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 11 best WordPress quiz plugins to boost user engagement and how to create a multi-page form in WordPress.
Comments Leave a Reply