Community Forums › Forums › Archived Forums › General Discussion › Problem with blogPosting functions.php – Genesis 2.2.6 update
- This topic has 6 replies, 4 voices, and was last updated 8 years, 3 months ago by emmtre.
-
AuthorPosts
-
January 6, 2016 at 4:59 pm #175793whiteminimanMember
Hi all,
I've a weird problem on a single page on my website. It's to do with the GitHub coding to add back in the blogPosting function.
Mentioned here - http://www.studiopress.com/releases/genesis-2-2-6.htm
GitHub code - https://gist.github.com/nathanrice/b90388e6b8052bf60583
And I've updated the functions.php in the Parallax theme.
I've a problem with this part of it:
/** * Output the entry image object. */ function nileswim_entry_image() { $img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'context' => is_singular() ? 'singular' : 'archive', 'attr' => genesis_parse_attr( 'entry-image', array ( 'alt' => get_the_title() ) ), ) ); list( $url, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); if ( ! empty( $img ) ) { $img = sprintf( '<a href="%s" aria-hidden="true">%s</a>', get_permalink(), $img ); } echo '<div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">'; echo $img; printf( '<meta itemprop="url" content="%s">', esc_url( $url ) ); printf( '<meta itemprop="width" content="%s">', esc_attr( $width ) ); printf( '<meta itemprop="height" content="%s">', esc_attr( $height ) ); echo '</div>'; } add_action( 'genesis_entry_content', 'nileswim_entry_publisher' );
The whole website all seems to be OK, except for this page
http://www.nileswimmers.org/who-we-are/management-team-sudan/
Which you can obviously see is pulling in that first image twice. Yet it doesn't do it on the UK page. I cannot for the life of me figure out what is going wrong, and which setting I need to tweak. If I comment out the code above, then the problem disappears.
Thanks in advance
http://www.nileswimmers.org/who-we-are/management-team-sudan/January 7, 2016 at 10:02 am #175855Victor FontModeratorI'm also using the Parallax Pro theme and the code is not working. I am also getting two images on posts. I removed the additional code until I can do further testing. Also, the new code produces a lot of errors if the publisher type is set to person. Logo is not a valid element for a person.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?January 11, 2016 at 3:10 pm #176253DeenaMemberBy following the directions to the best of my understanding, I am also getting a double image on the blog post page. I am using the News Pro child theme on an online news channel. Any updates on this?
Thanks! Deena
PS I saved a screenshot of the double image but with put stock functions text back for now.Child Theme: News Pro
Software all current WP, etc.
Site: kbhr933.comJanuary 11, 2016 at 5:38 pm #176266emmtreParticipantYou have to remove the genesis_entry_content action first and then add a new one with a different name like genesis_custom_post_image. I'm using the code below but you might have to adjust the hook genesis_before_entry_content and priority depending on your child theme. You also have to change the name of the featured image in wp_get_attachment_image_src to the one you are using. And you also have to remove the itemprop for entry images added by Genesis when using the code below to avoid duplicates. Please notice the conditional not is_singular since I'm using another code for single posts.
//* Add featured image meta for pages remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); add_action( 'genesis_before_entry_content', 'genesis_custom_post_image', 10 ); function genesis_custom_post_image() { if ( ! is_singular() && genesis_get_option( 'content_archive_thumbnail' ) ) { $img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'context' => 'archive', 'attr' => genesis_parse_attr( 'entry-image', array ( 'alt' => get_the_title() ) ), ) ); list( $url, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id(), 'featured' ); if ( ! empty( $img ) ) { echo '<div class="featured-image" itemprop="image" itemscope itemtype="https://schema.org/ImageObject">'; printf( '<a href="%s" aria-hidden="true">%s</a>', get_permalink(), $img ); printf( '<meta itemprop="url" content="%s">', esc_url( $url ) ); printf( '<meta itemprop="width" content="%s">', esc_attr( $width ) ); printf( '<meta itemprop="height" content="%s">', esc_attr( $height ) ); echo '</div>'; } } }
//* Remove markup for entry images add_filter( 'genesis_attr_entry-image', 'remove_entry_image_attributes' ); function remove_entry_image_attributes( $attributes ) { unset( $attributes['itemprop'] ); return $attributes; }
January 18, 2016 at 5:27 pm #176885DeenaMemberemmtre, should I paste the functions code in here or send privately? I replaced the functions code and the posts are working fine though if a second image is pasted into the post it looks fine in the exterior view but in the wp editor view the images and text view as if they ahve been pasted 2 times sometimes three times?
January 18, 2016 at 5:29 pm #176886DeenaMemberThis reply has been marked as private.January 20, 2016 at 9:20 pm #177059emmtreParticipantDeena, please contact StudioPress support if you haven't solved your problem yet.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.