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

    #1244749

    Hey Markus,

    Please provide a link to the site/page in question so we can look into this issue further.

    Best regards,
    Jordan Shannon

    #1245075
    #1245737

    Hi,

    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,
    Ismael

    #1245750

    Hallo Ismael,
    thanx is perfekt.

    I have one other request. See image
    – more space between category and heading
    – different font color

    https://meinwaldkirchen.de/wp-content/uploads/2020/09/more-space.jpg

    #1246152

    Hi,

    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,
    Ismael

    #1246345

    Hello 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)

    #1246693

    Hi,
    it would be great if someone could help me

    #1246776

    Hi,

    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:1

    Best regards,
    Ismael

    #1246795

    OK I deactivated the plugin

    #1246887

    Hi markmade,

    Do you need more help on this issue or did you get it resolved?

    Best regards,
    Victoria

    #1247032

    Yes,
    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 color

    https://meinwaldkirchen.de/wp-content/uploads/2020/09/more-space.jpg

    #1247118

    Hi 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,
    Victoria

    #1247124

    Hi Victoria,
    perfect thank you very much

    #1247125

    Hi markmade,

    Great :)

    We are closing the thread.

    If you need further assistance please let us know in a new one.

    Best regards,
    Victoria

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘enfold display subcategory on masonry’ is closed to new replies.