Missing arrows from gallery type post (in homepage)

Home Forums Modern Missing arrows from gallery type post (in homepage)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #20669

    mpaglia0
    Participant

    Missing arrows from gallery type post (in homepage)

    Resolved

    Hey there! Have you noticed this support service is provided FREE of charge?
    If you like the speed and accuracy of resolutions, please consider supporting me with a small donation. Thank you

    Consider a donation →

    My last posts with type ‘gallery’ do not show the arrows buttons anymore on the (preview on the homepage).
    Go here https://www.mauriziopaglia.it/
    The first two projects (Tutto torna & La metro di Napoli) are galleries but arrow buttons are not visible.
    Click on Raccolta Progetti and scroll the page down.
    When you reach Divagazione sulle finestre you can see the arrow buttons instead (normal behaviour).

    #20670

    Oliver Juhas
    Keymaster

    Hi mpaglia0,

    Thank you for reporting this. I think I know what could be the issue here. WordPress changed the post editor in version 5.0. Did you use this new editor in the posts that don’t display gallery in a slideshow?

    Best regards,

    Oliver Juhas
    WebMan Design

    #20671

    mpaglia0
    Participant

    Ciao Oliver,
    yes I am using Gutenberg and the post with the arrow buttons im place is rather old so – probably – has been created with WordPress 4.x

    #20672

    Oliver Juhas
    Keymaster

    Hi mpaglia0,

    Please note there is no easy fix for this right now. I’ll see what I can do and fix the issue in next theme update.

    Best regards,

    Oliver Juhas
    WebMan Design

    #20674

    Oliver Juhas
    Keymaster

    Hi mpaglia0,

    Actually, there is an issue with WordPress itself as several of its functions related to galleries stopped working with Gutenberg editor. You can read more in https://core.trac.wordpress.org/ticket/43826 bug report.

    I’ve put together a function you can use in your child theme‘s functions.php file now, until the WordPress bug is resolved (looking at the bug report, it seems this is planned for WordPress 5.2…):

    function child_theme_get_post_gallery( $gallery, $post ) {
    	$post = get_post( $post );
    
    	if (
    		$gallery
    		|| ! $post
    		|| ! function_exists( 'has_blocks' )
    		|| ! has_blocks( $post->post_content )
    	) {
    		return $gallery;
    	}
    
    	preg_match_all(
    		'/wp:gallery(.*)-->/i',
    		$post->post_content,
    		$galleries
    	);
    
    	if ( ! empty( $galleries[1] ) ) {
    		$gallery = json_decode( reset( $galleries[1] ), true );
    		foreach ( $gallery as $key => $value ) {
    			if ( is_array( $value ) ) {
    				$gallery[ $key ] = implode( ',', $value );
    			}
    		}
    	}
    
    	return $gallery;
    }
    add_filter( 'get_post_gallery', 'child_theme_get_post_gallery', 10, 2 );

    Best regards,

    Oliver Juhas
    WebMan Design

    #21040

    mpaglia0
    Participant

    Ciao Oliver,
    after the last update to 2.4.0 all works again!
    Thanks,
    Maurizio

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.