• ancawonka

    (@ancawonka)


    Hello there,

    I’ve been looking through the forum and the codex for this, but I can’t find it, even though I’m sure it’s obvious…

    I have set up several links categories, and I’d like to display each of them on individual pages that list out the links in that category.

    I know that this works through links.php – but how do I access this template?

    For example, I’ve got the links category “quicklinks” (That’s the slug)… I’ve tried:


    myblog.com/links/quicklinks
    myblog.com/link/quicklinks
    myblog.com/category/quicklinks
    myblog.com/link-category/quicklinks

    Needless to say searching the codex and the forum for “link pages” produces some non-relevant results.

    Help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    (@esmi)

    You could create some custom page templates and add something like:

    <ul class="linklist">
    <?php wp_list_bookmarks('category_name=Quicklinks&title_li=&categorize=0&show_description=1&orderby=name&between=<br />'); ?>
    </ul>

    with a different link category name in each template.

    Or, if you replicated the link category name in the page title, you might be able to get away with a single custom page template and use:

    <ul class="linklist">
    <?php wp_list_bookmarks('category_name='.the_title('','',false).'&title_li=&categorize=0&show_description=1&orderby=name&between=<br />'); ?>
    </ul>
    Thread Starter ancawonka

    (@ancawonka)

    Yeah, if I can’t figure out how to link to links, that’s what I’ll probably do (custom page template).

    If I use a page, I can also provide a nice formatted description of the link category. I can attach the links category to the page using a custom field (e.g. attach_links_category) that would allow me to add one or more link categories.

    esmi

    (@esmi)

    Custom fields was going be my third suggestion but wasn’t sure if that was pushing it a bit. ?? It would be my personal preference.

    Thread Starter ancawonka

    (@ancawonka)

    I decided to do it with a shortcode instead so that we could more easily organize the links. Here’s the code you would put in your functions.php file:

    // Linkfarm displays a list of links from a particular category
    function linkfarm_func($atts){
    	extract(shortcode_atts(array(
    			'category' => '',
    			'show_description' => true,
    			'orderby' => 'name'), $atts));
    
    	$out = 	wp_list_bookmarks(array(
    			'show_images' => false, 'show_description' => $show_description,
    			'show_name' => true,
    			'category_name' => $category,
    			'orderby' => $orderby, 'order' => 'ASC',
    			'title_li' => 'Related Links',
    			'echo' => false
    		));	
    
    	/* provide a link to edit the link category, so as to be friendly */
    
    	if (is_user_logged_in() && $category){ // add an 'edit' link to the widget header
    		global $userdata;
    		if ( ! isset($userdata) ) $userdata = get_currentuserinfo();
    		if ($userdata->user_level > 4){ // they are editors or admins
    			$edit_link =  "<a class='post-edit-link' href='" . get_bloginfo('url') . "/wp-admin/link-manager.php?cat_id=$category'>Edit</a>";
    			$out = $edit_link . $out;
    		}
    	}
    
    	return $out;
    
    }
    
    add_shortcode('linkfarm', 'linkfarm_func');

    The shortcode itself appears in the post like so:

    [linkfarm category="QuickLinks"]

    Thread Starter ancawonka

    (@ancawonka)

    But it would still be cool if there was a links page in WP, without having to jump through these hoops.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do I link to a page containing all links in a link category?’ is closed to new replies.