[Resolved] Categories order in entry-meta

Home Forums Support [Resolved] Categories order in entry-meta

Home Forums Support Categories order in entry-meta

  • This topic has 13 replies, 3 voices, and was last updated 1 year ago by Leo.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1457747
    maxime

    Hello,

    I customized my entry meta thanks to the documentation and some forum topics, however I couldn’t find one answer.

    If one article is present in 2 categories, for example, a post that is in categories WordPress and GeneratePress but the main one is WordPress.

    In the entry meta how can I make the main one to appear first ?

    The code I have right now is the following:

    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'date',
            'categories',
        );
    } );
    
    add_filter( 'generate_footer_entry_meta_items', '__return_false' );

    Thank you for your help

    #1457763
    Leo
    Staff
    Customer Support

    Hi there,

    Are you referring to parent/child categories here?

    #1457765
    maxime

    Hello Leo,

    In Gutenberg editor on the right sidebar you can choose categories and if you chose more than 1 you have to “Select the primary category”

    I don’t know if that would be consider as parent/child or not.

    #1457771
    Leo
    Staff
    Customer Support

    if you chose more than 1 you have to “Select the primary category”

    I don’t believe that’s a default option.

    Are you using any SEO plugin?

    #1457773
    maxime

    Oh okay, yes I do, Yoast SEO

    #1457786
    Leo
    Staff
    Customer Support

    Is the primary category always show last? or it’s random sometimes?

    Can you link me to the page in question?

    #1457787
    maxime

    Looks like there’s a fix order. I just started doing it for the last post, but I added categories here and there in the following posts for you to have more example.

    #1458321
    David
    Staff
    Customer Support

    Hi there,

    thats a tricky one.
    By default the category terms are output in abc order.
    To move the Yoast Primary category to the top of the list would require custom development i am afraid.

    #1458444
    maxime

    Okay I understand.

    No problem it was just a question that popped up in my mind when I realized this.

    But nothing to worry about so I’ll let it that way.

    Thank you David and Leo

    #1458494
    David
    Staff
    Customer Support

    No problems – sorry we couldn’t be of more help.

    #1458670
    maxime

    Actually, I thought of something. At least to add tags if I can. So the main category would be WordPress for example and there would be a tag next to it and that would be GeneratePress.

    In the code in my first message, how can I add tags right after the categories please ?

    Would it be ‘tags’, ?

    I’ll try this and see how it works. If it doesn’t don’t worry it wasn’t that big of a deal 🙂

    #1458749
    Leo
    Staff
    Customer Support

    That’s correct 🙂

    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'date',
            'categories',
            'tags',
        );
    } );
    
    add_filter( 'generate_footer_entry_meta_items', '__return_false' );
    #1458753
    maxime

    Perfect, thank you for your help 🙂

    #1458759
    Leo
    Staff
    Customer Support
Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.