-
AuthorPosts
-
September 9, 2020 at 12:30 pm #1244611
I only want to display the names of the subcategories with the code. What should the code be?
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’]);
//var_dump($categories);
$separator = ‘ ‘;
$output = ‘<div class=”ww-masonry-cat”>’;
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;
}
}
$output .= ‘</div>’;$key[‘text_before’] .= trim( $output, $separator );
return $key;
}// new script
add_action(‘wp_footer’, ‘ava_new_custom_script’);
function ava_new_custom_script(){
?>
<script type=”text/javascript”>
(function($) {
function a() {
var masonry = $(‘.av-masonry-entry’);
if(!masonry.length) return;
masonry.each(function() {
var cat = $(this).find(‘.ww-masonry-cat’);
$(this).find(‘.ww-masonry-title’).prepend(cat);
});
}a();
})(jQuery);
</script>
<?php
}September 10, 2020 at 6:00 am #1244749Hey Markus,
Please provide a link to the site/page in question so we can look into this issue further.
Best regards,
Jordan ShannonSeptember 11, 2020 at 8:28 am #1245075September 14, 2020 at 12:26 pm #1245737Hi,
Thank you for the update.
To display only sub categories, we could check if the parent property of the term or category is not equal to 0, which means that it has a parent term or category.
Please replace the avf_masonry_loop_prepare 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 = '<div class="ww-masonry-author">' . get_the_author() . '</div>'; $output .= '<div class="ww-masonry-cat">'; if ( ! empty( $categories ) ) { foreach( $categories as $category ) { if($category->parent != 0) { $output .= '<span alt="' . esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ) . '">' . esc_html( $category->name ) . '</span>' . $separator; } } } $output .= '</div>'; $key['text_before'] .= trim( $output, $separator ); return $key; }
Best regards,
IsmaelSeptember 14, 2020 at 1:10 pm #1245750Hallo Ismael,
thanx is perfekt.I have one other request. See image
– more space between category and heading
– different font colorhttps://meinwaldkirchen.de/wp-content/uploads/2020/09/more-space.jpg
September 16, 2020 at 5:25 am #1246152Hi,
You’re welcome! Glad it worked. If you have any additional questions at this time we kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.
Thanks!
Best regards,
IsmaelSeptember 16, 2020 at 2:46 pm #1246345Hello Ismael,
why should I open a new support ticket? It’s still about the same thing.
I just want help to edit the space and fontcolor in this particular case (see picture)September 18, 2020 at 8:17 am #1246693Hi,
it would be great if someone could help meSeptember 18, 2020 at 12:22 pm #1246776Hi,
Alright. We would like to check the site again but encountered a few jQuery errors from the svgs-inline-min.js file. Did you install a new plugin? Please disable those plugins first so that we could check the masonry element.
Uncaught ReferenceError: jQuery is not defined
https://meinwaldkirchen.de/wp-content/plugins/different-menus-in-different-pages-premium/public/js/different-menus-for-different-page-public.js?ver=2.2.0:32
different-menus-for-different-page-public.js:32:1Best regards,
IsmaelSeptember 18, 2020 at 12:51 pm #1246795OK I deactivated the plugin
September 18, 2020 at 6:06 pm #1246887Hi markmade,
Do you need more help on this issue or did you get it resolved?
Best regards,
VictoriaSeptember 20, 2020 at 2:22 am #1247032Yes,
I still need help on:Hallo Ismael,
thanx is perfekt.I have one other request. See image
– more space between category and heading
– different font colorhttps://meinwaldkirchen.de/wp-content/uploads/2020/09/more-space.jpg
September 20, 2020 at 1:55 pm #1247118Hi markmade,
Here is the code you can put in Enfold > General Styling > Quick Css, if it does not work, put into themes/enfold/css/custom.css
#top .ww-masonry-cat { color: #b0cb36; margin-bottom: 10px; }
If you need further assistance please let us know.
Best regards,
VictoriaSeptember 20, 2020 at 2:02 pm #1247124Hi Victoria,
perfect thank you very muchSeptember 20, 2020 at 2:02 pm #1247125Hi markmade,
Great :)
We are closing the thread.
If you need further assistance please let us know in a new one.
Best regards,
Victoria -
AuthorPosts
- The topic ‘enfold display subcategory on masonry’ is closed to new replies.