SamohtVII SamohtVII - 11 days ago 7
HTML Question

Printing links individually in Worppress

I basically want to create a category in the "Links" section of wordpress and add a number of links and titles for that category. Simple stuff.

I then want to be able to, in my template file, echo the links and title or anything about the link individually as i please. Preferably in a loop as I have some page building to do before and after the links.

I know 'category_before' and 'category_after' exist but they won't do what I need.

So I tried,

<?php $args = array(
'orderby' => 'name',
'order' => 'ASC',
'limit' => -1,
'category' => '3',
'hide_invisible' => 1,
'show_updated' => 0,
'echo' => 1,
'categorize' => 0,
'category_orderby' => 'name',
'category_order' => 'ASC',
'class' => 'linkcat',
'category_before' => '<tr><td>',
'category_after' => '</td></tr>' );
wp_list_bookmarks( $args );
?>


But that does a few things wrong. I don't need the category title or anything else besides the link text and destination really.

I am hoping to have a 'for' loop that will loop all links and I can just build my code section and links inside that, but let me know if there is a better way.

Thanks

EDIT: More Info

So I tried:

<?php
$taxonomy = 'link_category'; // Taken from the DB table
$tax_terms = get_terms( $taxonomy, array( 'hide_empty' => false ) );
?>
<ul>
<?php
foreach ($tax_terms as $tax_term) {
echo $tax_term->name;
}
?></ul>


Which is the closest I have got. This only returns the info about the category not what is in the category.

There is nothing in the "wp_term_taxonomy" table in the DB about the actually category I have made.

Thanks again

EDIT:
Here is the area I'm referring to:

I want to show these 2 links

Answer

You may want to try the get_bookmarks function.

$bookmarks = get_bookmarks( array(
    'orderby'        => 'name',
    'order'          => 'ASC',
    'category_name'  => 'category-name'
));

// Loop through each bookmark and print formatted output
foreach ( $bookmarks as $bookmark ) { 
    printf( '<a class="relatedlink" href="%s">%s</a><br />', $bookmark->link_url, $bookmark->link_name );
}

https://codex.wordpress.org/Function_Reference/get_bookmarks