Black Friday sale! Get 25% off WPSP Pro! Discount automatically applied at checkout.

[Resolved] Display categories as tags

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Display categories as tags

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #5260
    Janek
    Participant

    Good afternoon,

    Just wondering if theres a simple way to enable the display of categories on the front end within the area that displays tags. Currently I can only get my taxonomy to display if I manually select the taxonomy to display in the list. Otherwise it just shows blank. This is ok except the categories will be removed and added to on occasion and Id prefer the client not have to touch the WP Show Post settings.

    I hope Im explaining this correctly.

    #5266
    Tom
    Keymaster

    It’s currently not possible by default, but you may be able to do something like this:

    add_filter( 'wpsp_terms_output', function( $output ) {
    	$categories_list = sprintf(
    		'<span class="categories-list">%s</span>',
    		get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'wp-show-posts' ) )
    	);
    
    	return $output . $categories_list;
    } );
    #5273
    Janek
    Participant

    Hey Tom,

    Is there a way to remove the comma separator between the categories?

    #5283
    Tom
    Keymaster

    Replace:

    get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'wp-show-posts' ) )

    With:

    get_the_category_list( '' )

    #5286
    Janek
    Participant

    At the moment I have:

    add_filter( 'wpsp_terms_output', function( $output ) {
    	$categories_list = sprintf(
    		'<span class="categories-list">%s</span>',
    		get_the_category_list( '' ) 
    	);
    
    	return $output . $categories_list;
    } );

    Yet nothing is being affected on the front end. I’m using a CPT if that matters the post type is ‘team’.

    Its odd because I could have sworn the list wasnt displaying any categories in the tags without this code now everything is working fine even with the code snippet removed. I just cant get rid of that damned comma!

    #5299
    Tom
    Keymaster

    Hmm, can you link me to the page?

    #5303
    Janek
    Participant

    http://janek-dev.flywheelsites.com/team/

    Let me know if you need the logins and I’ll re-email.

    #5319
    Tom
    Keymaster

    Yes please 🙂

    We don’t store any login info, so it’s always best to email it when needed: https://wpshowposts.com/contact/

    #5322
    Janek
    Participant

    You should have the login details now to view the site. 🙂

    http://janek-dev.flywheelsites.com/episodes/

    #5329
    Tom
    Keymaster

    I’m not seeing any of the terms/categories on that page? Are terms themselves activated?

    #5330
    Janek
    Participant

    Sorry I sent you the wrong page. Got confused with my support tickets.

    http://janek-dev.flywheelsites.com/team/

    Thats the correct one for the tags/categories!

    #5335
    Tom
    Keymaster

    That’s really strange. Any other functions related to WPSP added to the site?

    #5340
    Janek
    Participant

    I have a couple of snippets running, but nothing that should prevent modification of the Tags.

    I disabled all of them and it still made no difference…

    #5359
    Tom
    Keymaster

    Hmm, what if you do this?:

    add_filter( 'wpsp_terms_output', function( $output ) {
    	$categories_list = sprintf(
    		'<span class="categories-list">%s</span>',
    		get_the_category_list( '' ) 
    	);
    
    	return 'hi!' . $output . $categories_list;
    } );

    Can you see the text hi!?

    #5360
    Janek
    Participant

    Yes it does! 😮

    I’ve disabled the snippet temporarily. So if you visit the site now it wont show, but it was definitely outputting ‘hi’ in the tag line.

    • This reply was modified 2 years, 4 months ago by Janek.
Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.