Tagged: author's name, category, masonry
-
AuthorPosts
-
November 26, 2018 at 1:18 am #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?November 28, 2018 at 1:06 pm #1038483Hey 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-420057If you need further assistance please let us know.
Best regards,
VictoriaNovember 28, 2018 at 6:56 pm #1038665Dearv 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, 2018Can you suggest a solution?
Thanks
(i added in the previous post the needed login data)November 29, 2018 at 4:53 pm #1039022Hi 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,
VictoriaNovember 29, 2018 at 5:37 pm #1039061Could you – at least – explain how to add the category before the title?
Unfortunately all the post indicated did not provide a complete solution.
RegardsNovember 30, 2018 at 3:22 pm #1039333Hi lorenzopaolini,
This solution can help you achieve that
https://kriesi.at/support/topic/inject-category-name-into-masonry-element/#post-617984If you need further assistance please let us know.
Best regards,
VictoriaNovember 30, 2018 at 6:42 pm #1039398Ismael 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 youDecember 2, 2018 at 8:17 am #1039810Hi,
Please try it at the bottom of you child theme functions.php file to see if you have any luck with it.
Best regards,
RikardDecember 2, 2018 at 1:51 pm #1039925I 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’);December 2, 2018 at 2:06 pm #1039933I 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 … …
December 4, 2018 at 6:35 pm #1040845Hi lorenzopaolini,
Can you give us ftp access? so we can try to modify your functions.php without risk.
Best regards,
NikkoDecember 5, 2018 at 2:42 pm #1041227Thank you for help:
- This reply was modified 5 years, 11 months ago by Victoria.
December 8, 2018 at 6:22 pm #1042510toc toc…. I sent access data, any news? thanks
December 10, 2018 at 3:14 pm #1043109Hi 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,
NikkoDecember 10, 2018 at 7:51 pm #1043293Thank 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 cooperationDecember 12, 2018 at 10:06 pm #1044519Hi 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,
NikkoDecember 12, 2018 at 10:56 pm #1044561Fantastic! You really helped me!!!!
Thank you very much :))))))
LorenzoDecember 13, 2018 at 1:33 am #1044649Hi 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,
NikkoAugust 4, 2021 at 12:29 pm #1314367Can 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?
August 6, 2021 at 4:26 am #1314740Hi 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 -
AuthorPosts
- You must be logged in to reply to this topic.