WP_query for links? (1 post)

  1. guitarcrazy087
    Posted 7 years ago #

    I'm looking to make a list of three random links for my site. I have worked with the wp_list_bookmarks() function and done everything possible with it but have found that it is impossible to style my links like I would like to.

    I'm wondering if any of you know a way to query for WordPress links like you would normally with PHP or using the WP_query?

    I was trying something like this:

    $my_query = new WP_query('SELECT link_url, link_name, link_target, link_description FROM wp_links WHERE link_visible="Y" ORDER BY RAND() LIMIT 3');
    // I believe my problem is here... I don't know how to capture the queried data in variables...
    	$name = $post->link_name;
    	$url = $post->link_url;
    	$target = $post->link_target;
    	$description = $post->link_description;
    	$description = cropsentencepost($description, 200, "...", $name, ' - ');
    	echo "	<div class=\"link\"><a href=\"$url\" target=\"$target\">$name</a><small> - $description</small></div>\n";

    This could be way off, but it at least doesn't give my any error messages. It just doesn't display the data.

    Thanks in advance, any help is really appreciated!

Topic Closed

This topic has been closed to new replies.

About this Topic