Add Categories & Tags To Genesis Featured Posts Widget

This code enables you to add the same links for categories and tags included in the entry footer of each post entry to the entry footer in the Genesis featured posts widget.

By default, the Genesis featured posts widget doesn’t include links for categories and tags. It only includes post info links in the entry header which you can see in the following image of the widget:

The solution in this tutorial adds another small box to the genesis featured posts widget as you can see in the following image:

You can position the new settings box for categories and tags anywhere in the widget. In this case, it’s been added after the box which contains the settings for post info as seen in the following image:

Here’s the front end result:

Here’s the code for logged in members:

Related Tutorials


Comments

6 responses to “Add Categories & Tags To Genesis Featured Posts Widget”

  1. Matt Montgomery Avatar
    Matt Montgomery

    Hello,

    This is working great for me, however I need to remove ‘Filed under’, the separator, and one specific category. I’m also removing the link, and moving the category above the feature image.

    I thought I had it all figured out, but the code I’m using to remove the category does not work when I change [post_categories] to [post_categories before=”” sep=””] in the featured posts widget settings.

    Let me know if you can assist, I will share site and give some more detail.

    1. Hello Matt. Is this globally or only for the featured posts widget?

      What code are you using to remove the category? Also, link to the source.

      1. Matt Montgomery Avatar
        Matt Montgomery

        I want to remove ‘Filed under’ and the separator globally, but only remove the category archive link from the Featured posts widgets (I have 2 on my homepage).

        This is how I removed the ‘Featured’ category:
        [code]
        function exclude_these_categories($thelist, $separator=”) {
        //Exclude the following categories
        $exclude = array(‘Featured’);
        $cats = explode($separator, $thelist);
        $newlist = array();
        foreach($cats as $cat) {
        $catname = trim(strip_tags($cat));
        if(!in_array($catname, $exclude))
        $newlist[] = $cat;
        }
        return implode($separator, $newlist);

        }
        add_filter(‘the_category’,’exclude_these_categories’, 10, 2);
        [/code]
        This is how I removed the link:
        [code]
        function no_links($thelist) {
        return preg_replace(‘#<a.?>([^<])#i’, ‘$1’, $thelist);
        }

        add_filter( ‘the_category’, ‘no_links’ );
        [/code]
        So on my front page I have one featured posts widget that has posts tagged with the normal category and ‘Featured’ (which I don’t want to show). The second featured posts widget shows the rest of our articles from all categories (excluding featured posts that have already been shown).

        Site is: mstrdev.wpengine.com

        1. Try the code in this new tutorial i published for you.

          So you need to do 4 things :

          Remove ‘Filed under’
          Remove the separator
          Exclude 1 category
          Remove the category archive link ( for 1 or all categories? from the Featured posts widgets ( does this mean you also want to display the category name and only remove the link? )

          My advice to you is to use a custom function to add the category and tags links in the featured posts widget ( rather than the default [[post_categories]] [[post_tags]] shortcodes ) and use the filter hooks built into the default Genesis shortcodes to modify the default output.

          1. Matt Montgomery Avatar
            Matt Montgomery

            I need to remove one specific category name and link (globally). The other categories should be displayed, and not linked (but only on the front page in feature post widgets). On posts pages, those categories should be displayed and link to archive pages normally. I just ended up hiding the links with CSS.

            I was also able to remove the ‘filed under’ and separator a few different ways including with a new short code for outputting post_categories. It seems the issue I’m having is with my function to remove the one specific category. The code I found (above) works until I remove the separator and ‘filed under’. As soon as those are removed, no matter which way I do it, ‘Featured’ category reappears.

            Btw I had no experience with PHP or Genesis before starting this project a few weeks ago. I’m learning slowly, and I understand the gist of your recommendation above but I am going to struggle to write the function myself.

            Thanks for your responses, and any further assistance you can provide!

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.