Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
April 5, 2016 at 2:43 pm #608314
I’m using the code to display the category.
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 == 'the_title' ) { $value .= "<div class='av-masonry-categories'>".$cat."</div>"; } $key[$post] = $value; } return $key; }
Two problems with the given code.
1 – Its removing special chars like áéíóú
2 – I would like to display above the titleApril 7, 2016 at 3:24 am #609279i really dont feel that im getting the suport that i’ve paid for.
Is this topic still active?April 7, 2016 at 8:25 am #609426Hi,
Please send us a temporary admin login so that we can have a closer look. You can post the details in the Private Content section of your reply.
Regards,
RikardApril 7, 2016 at 1:50 pm #609613April 11, 2016 at 4:26 am #610914Hi!
We are very sorry for the delay. The code above doesn’t really fetch the actual category of the posts. It utilizes the class attribute of the masonry items which contains the category name (ex: category-namehere). Please replace the code with this:
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 = ''; if ( ! empty( $categories ) ) { foreach( $categories as $category ) { $output .= '<span alt="' . esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ) . '">' . esc_html( $category->name ) . '</span>' . $separator; } } $key['text_after'] .= trim( $output, $separator ); return $key; }
Best regards,
Ismael -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.