Community Forums › Forums › Archived Forums › General Discussion › Title attribute on feature images
Tagged: attribute, feature image, title
- This topic has 4 replies, 2 voices, and was last updated 9 years ago by SirTzusky.
-
AuthorPosts
-
September 10, 2015 at 4:47 am #165093SirTzuskyMember
Hi everyone,
I'm having problems displaying title attribute on feature images.
I use grid loop to show my posts on archive pages like homepage or so: http://4kwallpapers.co/
Here's my function wich I use to display the grid:function child_grid_loop() { //* Global vars global $_genesis_loop_args; //* Parse args $args = apply_filters( 'genesis_grid_loop_args', wp_parse_args( $args, array( 'grid_image_size' => 'grid-thumbnail', 'grid_image_class' => 'alignleft', 'grid_content_limit' => 0, 'more' => '', ) ) ); //* What page are we on? $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; //* Set global loop args $_genesis_loop_args = $args; //hooks and filters for if ( !is_page_template( 'page-info.php' ) || is_home() || is_archive()) { remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); add_action( 'genesis_entry_header', 'genesis_do_post_image', 8 ); remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 ); remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 ); remove_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); } //* The loop genesis_standard_loop(); //* Reset loops genesis_reset_loops(); remove_filter( 'post_class', 'genesis_grid_loop_post_class' ); remove_action( 'genesis_post_content', 'genesis_grid_loop_content' ); remove_action( 'genesis_entry_content', 'genesis_grid_loop_content' ); }
Any help will be appreciated,
http://4kwallpapers.co/
Thank you,
GabrielSeptember 10, 2015 at 5:28 am #165099Victor FontModeratorWhen you say title attribute, are you referring to the image title attribute or the post title? The genesis_do_post_image function calls the WordPress wp_get_attachment_image function to create the image element. Assuming you've added a title attribute through the media library to each image, the wp_get_attachment_image function contains a foreach loop that adds all image related attributes to the img tag. The image title attribute is not a display element. If you want the post title, then don't remove it as you are doing in your code.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?September 10, 2015 at 2:05 pm #165157SirTzuskyMemberHi Victor,
Thank you for your answer.
Yes, I'm referring to the image title attribute. Not the post title (this I remove on purpose).Can you tell me more specifically how I use the wp_get_attachment_image function to display the title attribute in the above child_grid_loop function? My WordPress/Genesis knowledge is not that good.
Thank you in advance,
GabrielSeptember 10, 2015 at 2:21 pm #165158Victor FontModeratorThe code below will retrieve an image title. You'll have to figure out how to add it to your loop:
$title = get_post(get_post_thumbnail_id())->post_title;
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?September 10, 2015 at 11:53 pm #165190SirTzuskyMemberThank you for your answer. I just take a look on other child themes from Genesis. It seems that none of them use title attribute on loops...that's odd...
-
AuthorPosts
- The topic ‘Title attribute on feature images’ is closed to new replies.