Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • #1037501

    I would like to add after the title also the Author’s name and category. I use Masonry for Home Page Blog and now only the Title is shown on the first line and the date in second line.
    I would prefere that in secon line appears Author’s name, Category and the date in a third line.
    Can you help me?

    #1038483

    Hey lorenzopaolini,

    There are a few solutions posted in these threads:
    https://kriesi.at/support/topic/inject-category-name-into-masonry-element/
    https://kriesi.at/support/topic/post-category-in-the-mesonary-blog/#post-420057

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1038665

    Dearv Victoria,
    the suggested post are not solving my particular case.
    I would like to add BOTH the category and the name of Author of the post, as per following example:

    CATEGORY Title of the post
    John Smith, Nov, 25, 2018

    Can you suggest a solution?
    Thanks
    (i added in the previous post the needed login data)

    #1039022

    Hi lorenzopaolini,

    You can take one of the snippets and work on them to add the author or format it as you need.

    Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you :)

    Best regards,
    Victoria

    #1039061

    Could you – at least – explain how to add the category before the title?
    Unfortunately all the post indicated did not provide a complete solution.
    Regards

    #1039333

    Hi lorenzopaolini,

    This solution can help you achieve that
    https://kriesi.at/support/topic/inject-category-name-into-masonry-element/#post-617984

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1039398

    Ismael tells to add the following code:
    Replace the javascript with this:

    // new script
    add_action(‘wp_footer’, ‘ava_new_custom_script_masonry’);
    function ava_new_custom_script_masonry(){
    ?>
    <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();

    $(window).on(‘debouncedresize av-height-change’, function() {
    setTimeout( a(), 300 );
    });
    })(jQuery);
    </script>
    <?php
    }

    BUT I HAVE TO ADD THIS CODE, WHERE? Please specify in what file and in what position.
    Thank you

    #1039810

    Hi,

    Please try it at the bottom of you child theme functions.php file to see if you have any luck with it.

    Best regards,
    Rikard

    #1039925

    I inserted from line 729 the script as you suggested, I also cleared the cache, but nothing changes. I enclose final part of functions.php by copying it from line 686 to show you what I have done.
    ————————————
    * Remove the default shortcode function, we got new ones that are better ;)
    */
    add_theme_support( ‘avia-disable-default-shortcodes’, true);

    /*
    * compat mode for easier theme switching from one avia framework theme to another
    */
    add_theme_support( ‘avia_post_meta_compat’);

    /*
    * make sure that enfold widgets dont use the old slideshow parameter in widgets, but default post thumbnails
    */
    add_theme_support(‘force-post-thumbnails-in-widget’);

    /*
    * display page titles via wordpress default output
    *
    * @since 3.6
    */
    function av_theme_slug_setup()
    {
    add_theme_support( ‘title-tag’ );
    }

    add_action( ‘after_setup_theme’, ‘av_theme_slug_setup’ );

    /*title fallback (up to WP 4.1)*/
    if ( ! function_exists( ‘_wp_render_title_tag’ ) )
    {
    function av_theme_slug_render_title()
    {
    echo “<title>” . avia_set_title_tag() .”</title>”;
    }
    add_action( ‘wp_head’, ‘av_theme_slug_render_title’ );
    }
    // new script
    add_action(‘wp_footer’, ‘ava_new_custom_script_masonry’);
    function ava_new_custom_script_masonry(){
    ?>
    <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();

    $(window).on(‘debouncedresize av-height-change’, function() {
    setTimeout( a(), 300 );
    });
    })(jQuery);
    </script>
    <?php
    }

    /*
    * register custom functions that are not related to the framework but necessary for the theme to run
    */

    require_once( ‘functions-enfold.php’);

    /*
    * add option to edit elements via css class
    */
    // add_theme_support(‘avia_template_builder_custom_css’);

    #1039933

    I had to remove the script you suggested because it causes errors in scrolling the menu. If you can help me do it, it’s useless for me to wish me luck … …

    #1040845

    Hi lorenzopaolini,

    Can you give us ftp access? so we can try to modify your functions.php without risk.

    Best regards,
    Nikko

    #1041227

    Thank you for help:

    • This reply was modified 5 years, 11 months ago by Victoria.
    #1042510

    toc toc…. I sent access data, any news? thanks

    #1043109

    Hi lorenzopaolini,

    I apologize for the late response, I have added this code at the bottom of functions.php:

    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 ) {
                $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_masonry');
    function ava_new_custom_script_masonry(){
    ?>
    <script type="text/javascript">
    (function($) {
        function a() {
            var masonry = $('.av-inner-masonry-content');
            if(!masonry.length) return;
            masonry.each(function() {
                var author = $(this).find('.ww-masonry-author');
                $(this).find('.av-masonry-entry-title').insertBefore(author);
            });
        }
    
        a();
    
        $(window).on('debouncedresize av-height-change', function() {
            setTimeout( a(), 300 );
        });
    })(jQuery);
    </script>
    <?php
    }
    

    if you want to modify the css of the author you can use this:

    .ww-masonry-author {
      color: black;
    }

    Let us know if you need further assistance.

    Best regards,
    Nikko

    #1043293

    Thank you for your kind assistance, but now in ALL the articles appears the same name: Lorenzo Paolini.
    Lorenzo Paolini is me, the admin of the site, but we need that in the same position will appear the name of the single Author of the article.
    For instance, for the article “Il marketing dell’Anima” Author is “Piero Priorini”:
    Thank you for your cooperation

    #1044519

    Hi lorenzopaolini,

    I have modified the filter code to:

    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']);
    		$author_id = get_post_field( 'post_author', $key['ID'] );
    	
    		$separator = ' ';
        $output = '<div class="ww-masonry-author">' . get_the_author_meta( 'display_name', $author_id ) . '</div>';
        $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;
    }

    Let us know if you need further assistance.

    Best regards,
    Nikko

    #1044561

    Fantastic! You really helped me!!!!
    Thank you very much :))))))
    Lorenzo

    #1044649

    Hi Lorenzo,

    Glad to hear that, it’s a pleasure that we could help :)
    Feel free to create a new thread if you need further assistance.
    Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

    #1314367

    Can I also use this code for a specific user? When I use this code, it seems to use the first user created, as example user1. I’ve created user2 and linked all posts to user2, but user1 still pops up. Any advice?

    #1314740

    Hi Dave,

    The code just gets the author of the post/portfolio so it should show only the same author even with different users.
    Can you give us more context on this? so we can try to understand better what you’re trying to achieve.

    Best regards,
    Nikko

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