Support » Plugin: Very Simple Knowledge Base » Display categories filtered by tag

  • Resolved lizwoo

    (@lizwoo)


    Hi there,
    Thank you so much for this plugin! It has been the most efficient and easiest to use plugin I have tested for displaying post categories.

    My question is this: Is it possible to display posts in a grid by category but filtered to show only posts with specific tags?

    So for instance, my knowledgebase is a large list of workflows and instruction that pertain to different library software systems. Let’s say I have five categories for library workflows (Cataloging, Acquisitions, Receiving, Invoicing, Circulation) and four tags for the software names (Aleph, Sierra, Alma, Millenium). All software uses the same categories of workflow, but the specific instructions vary per software system. Could I use this plugin on four separate pages (one for each software tag) that would display the same five categories of workflows, but only show the posts that were tagged for that specific software?

    I think this is a slight variation on what I am seeing – whenever I use the tag portion, it shows the posts sorted by tag name rather than category. I want to use the data from both taxonomies, but indicate which one takes precedence in the display and which one should be used as the filter.

    Thanks for your help!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Guido

    (@guido07111975)

    Hi,

    It should be possible to list posts by tag, please check info on plugin page:

    Post tags
    Besides categories you can also list native post tags: [knowledgebase taxonomy="post_tag"]

    Update: I now understand what you want to accomplish..

    Did you already try to add both taxonomies?

    [knowledgebase taxonomy="category, post_tag"]
    (not tested, yet)

    And together with the include and exclude attribute.

    Guido

    Thread Starter lizwoo

    (@lizwoo)

    Hi there,

    Thank you so much for getting back to me so quickly! I had tried both taxonomies originally, but didn’t structure it correctly. So, thank you for modeling the correct structure.

    I just tried your suggestion

    [knowledgebase taxonomy=”category, post_tag”]

    but it doesn’t render anything on the page.

    Thanks again for your help!
    Liz

    Plugin Author Guido

    (@guido07111975)

    Hi Liz,

    Too bad. I have to create a test environment for this, so I will keep you informed.

    Guido

    Plugin Author Guido

    (@guido07111975)

    Hi again,

    Are you able to tweak your VSKB plugin?

    1) Open file “vskb-list” and look for string:

    
    foreach( $vskb_posts AS $single_post ) :
    

    Add this underneath:

    
    $posttags = get_the_tags($single_post->ID);
    if ($posttags) {
    	$tags = array();
    	foreach($posttags as $tag) {
    		$tags[] = $tag->slug;
    		$the_tags = join( " ", $tags );
    	}
    } else {
    	$the_tags = '';
    }
    

    2) Look for this string:

    
    $return .= '<li class="vskb-post-name">';
    

    Change into:

    
    $return .= '<li class="vskb-post-name '.$the_tags.'">';
    

    Now the post tags are being added to the CSS class of your knowledgebase posts.

    3) Hide the posts of certain tags on the category page, by using custom CSS.
    Example: if you want to hide the 3 tags “Sierra, Alma, Millenium” on category page “Cataloging”, look for the ID of that page (for example 156) and add this at the CSS page in Customizer:

    
    .page-id-156 li.sierra, .page-id-156 li.alma, .page-id-156 li.millenium {display:none;}
    

    Now all posts with those 3 tags are hidden on that page. Repeat that for the other category pages.

    No, this is not a very clean fix but it does work just fine 😉

    I might add this or something similar in a future update as well..

    Guido

    Plugin Author Guido

    (@guido07111975)

    Liz,

    I’ve updated plugin few moments ago. Just update it and you only need to do step 3 mentioned in my previous reply. So hide the posts of the relevant tags by using custom CSS.

    Guido

    Thread Starter lizwoo

    (@lizwoo)

    Hi Guido,
    Wow, this is great! Thank you for making that fix and for updating the plugin. I was able to make the irrelevant posts disappear pretty easily. A blank category heading still stays, but I think I can just eyeball those and get rid of that with the exclude functionality you have already built into the plugin.

    One last question – if I have a post that is in more than one category/tag – which takes precedent? Inclusion or Exclusion

    For example: If I build this code into a page where I intend to list by category all the posts with tag “A”, but one of my posts is tagged for both “A” AND “B”, will the code remove out ALL posts that have the tag of B, regardless of if the “A” tag is also selected?

    Thank you again for all the help you have been. I’ve spent a lot of time trying to make this work and your plugin has been amazing!
    Liz

    Plugin Author Guido

    (@guido07111975)

    Hi Liz,

    If I understand correctly, you needed all categories at all pages, but you wanted to hide posts that contained certain tags, depending on the page?

    If a post contains 2 tags (for example siera and alma), and you’ve already hidden the first tag (sierra) on the relevant page, you could still display the post via this tweak:

    
    .page-id-156 li.sierra {display:none;}
    .page-id-156 li.alma {display:block;}
    

    Guido

    Thread Starter lizwoo

    (@lizwoo)

    Hi Guido,
    That does the trick! Thank you so much for both your help and your quick responses. I am very excited to get this up and going!
    Thanks again,
    Liz

    Plugin Author Guido

    (@guido07111975)

    Hi Liz,

    Great to hear! And you’re very welcome 🙂

    Guido

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Display categories filtered by tag’ is closed to new replies.