WordPress- How do I display link categories per post?

I currently have several different link categories with links within them. My goal is to have the edit-screen of any post display these link categories so that I can select a category of links to display on that particular post.

I’m currently using the Related Links plugin but it does not incorporate link categories.

Read More

As an example, I would like to create a post and select from the backend a particular link category, which will display all those links within that post.

I have spent hours trying to find a plugin that would accomplish this, but none seem to do what I would like.

Ideally, I would like to have a popdown to select from the backend, without having to user Custom Fields.

I am limited in my knowledge of PHP, and defer to the experts at SO to assist in accomplishing my goal. Thank you!

Related posts

Leave a Reply

1 comment

  1. You’ll have to use a Custom Meta Box to handle Custom Fields in a nice interface. There are several examples in WordPress Answers, here’s one of mine very similar to what you need.

    To grab the Link Categories, we need get_terms('link_category'), which returns an array that we use in the dropdown selector. This example dumps the array just after a post title:

    add_action( 'edit_form_after_title', 'dump_link_cats_so_13852089' );
    
    function dump_link_cats_so_13852089()
    {
        global $post;
        if( 'post' != $post->post_type )
            return;
    
        # Use this in your Custom Meta Box  
        $link_cats = get_terms( 'link_category', array( 'hide_empty'=>false ) );
        var_dump( $link_cats );
    }
    

    enter image description here