Site logo

Archived topic

Categories order in entry-meta

13 replies · Started by maxime on September 24, 2020

Viewing posts 1–14 of 14

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

Hi there,

Are you referring to parent/child categories here?

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.

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?

Oh okay, yes I do, Yoast SEO

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

Can you link me to the page in question?

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.

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.

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

No problems - sorry we couldn't be of more help.

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 :)

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' );

Perfect, thank you for your help :)

No problem :)

This archived topic is closed to new replies.