Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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

    #585552

    Hi!

    Can you paste the code you’re using?

    Best regards,
    Josue

    #585621
    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;
    }
    #585652

    Ok, can you post a link to the page in question?

    Cheers!
    Josue

    #585914

    Sure

    #585969

    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

    #585974

    Perfect, MANY THANKS!

    #585979

    You are welcome, glad to help :)

    Regards,
    Josue

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.