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
Hi!
Can you paste the code you’re using?
Best regards,
Josue
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 ) {
if ( $post == 'content' ) { $value .= "<div class='av-masonry-categories'>".$cat."</div>"; }
$key[$post] = $value;
}
return $key;
}
Ok, can you post a link to the page in question?
Cheers!
Josue
Sure
Check 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,
Josue
Perfect, MANY THANKS!
You are welcome, glad to help :)
Regards,
Josue