-
AuthorPosts
-
June 29, 2018 at 7:36 am #979201
Hi guys, Hope all are doing well.
I have posted a question in this thread: https://kriesi.at/support/topic/post-category-in-the-mesonary-blog/
But this seems to be closed now, so creating a new one.
I got category on top of my post title, but when i give two categories, we need to add a comma in between. Can we show parent category first and its child after it.
For example, in this screenshot: http://prntscr.com/k0o28e
‘Explore’ is parent category and others are child. As you can see in third one, child category is coming before the parent one. This is sorting Alphabetically.
It will be great if you can help in this.
Kind Regards
ManpreetJuly 2, 2018 at 8:57 am #980006Hey torahulparashar,
Thank you for using Enfold.
You should adjust the separator value.
$separator = ', ';Add comma instead of space. Or replace the whole filter with this one.
add_filter( 'avf_masonry_loop_prepare', 'avf_masonry_loop_prepare_mod_cat', 10, 2 ); function avf_masonry_loop_prepare_mod_cat( $key, $entries ) { $categories = get_the_category($key['ID']); $separator = ', '; $output = ''; $items = count($categories); $i = 0; if ( ! empty( $categories ) ) { foreach( $categories as $category ) { if($i++ === $items) { $separator = ''; } $output .= '<span alt="' . esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ) . '">' . esc_html( $category->name ) . '</span>' . $separator; } } $key['text_before'] .= trim( $output, $separator ); return $key; }Best regards,
IsmaelJuly 2, 2018 at 9:20 am #980015Thankyou Ismael. It worked.
Kind Regrads
July 3, 2018 at 6:43 am #980402Hi,
Great, glad you got it working. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardJuly 3, 2018 at 6:49 am #980405Hello, It is working for now. Not sure about future if I need anything else in it. You can close the topic if you wish to.
Kind Regards
July 3, 2018 at 7:07 am #980412 -
AuthorPosts
- The topic ‘Post Category in Masonary Gallery’ is closed to new replies.
