Viewing 8 posts - 1 through 8 (of 8 total)
-
AuthorPosts
-
February 16, 2016 at 12:56 pm #584135
Hi There,
we need post category in the masonry blog. And we’ve found the following solution: https://kriesi.at/support/topic/post-category-in-the-mesonary-blog/
The unsolved problem there: its showing the Category Slug insted the Category Name.
Do you have a solution?
Thanks
February 18, 2016 at 6:17 pm #585552Hi!
Can you paste the code you’re using?
Best regards,
JosueFebruary 18, 2016 at 7:42 pm #585621add_filter( 'avf_masonry_loop_prepare', 'avf_masonry_loop_prepare_mod', 10, 2 ); function avf_masonry_loop_prepare_mod( $key, $entries ) { $class = preg_grep('/category/', $key['class']); $getstr = str_replace('category-', '', implode(',', $class)); $categories = explode(',', $getstr); $cat = implode(',', array_map('ucfirst', $categories)); foreach ( $key as $post => $value ) { if ( $post == 'content' ) { $value .= "<div class='av-masonry-categories'>".$cat."</div>"; } $key[$post] = $value; } return $key; }February 18, 2016 at 8:17 pm #585652Ok, can you post a link to the page in question?
Cheers!
JosueFebruary 19, 2016 at 9:08 am #585914Sure
February 19, 2016 at 12:09 pm #585969Check it now, i changed the code to:
/* Catogory in Masonry Blog */ add_filter( 'avf_masonry_loop_prepare', 'avf_masonry_loop_prepare_mod', 10, 2 ); function avf_masonry_loop_prepare_mod( $key, $entries ) { $class = preg_grep('/category/', $key['class']); $getstr = str_replace('category-', '', implode(',', $class)); $categories = explode(',', $getstr); $cat = implode(',', array_map('ucfirst', $categories)); foreach ( $key as $post => $value ) { $term = get_term_by('slug', $cat, 'category'); if ( $post == 'content' ) { $value .= "<div class='av-masonry-categories'>".$term->name."</div>"; } $key[$post] = $value; } return $key; }Best regards,
JosueFebruary 19, 2016 at 12:24 pm #585974Perfect, MANY THANKS!
February 19, 2016 at 12:33 pm #585979You are welcome, glad to help :)
Regards,
Josue -
AuthorPosts
Viewing 8 posts - 1 through 8 (of 8 total)
- You must be logged in to reply to this topic.
