• Resolved sdotsamuel

    (@sdotsamuel)


    I recently purchased Ajax Load More with the Previous Post add on and I have noticed some odd behavior with it.

    When I read the first post with an Instagram Embed in it, the Instagram shows up fine. However, when it loads the second post (and beyond) which has an Instagram embed in it, the Instagram fails to load.

    In the post, I am just posting the URL of the Instagram URL and Jetpack handles the rest.

    I wrote the developer on the same topic, and he said:

    “That isn’t all that odd.
    When scripts require JavaScript the render you need to initiate them after Ajax calls.

    With previous Post, the first posts is NOT loaded with Ajax so Instagram will load as expected.

    Which Instagram plugin are you using?”

    https://wordpress.org/support/topic/instagram-not-loading-2/

    I’m not a javascript developer so his explanation means nothing to me.

    Is there anything I should be doing to make this work?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    That can indeed happen, depending on the method you use to insert the Instagram photos in your posts.

    When using Jetpack’s Instagram shortcode, Jetpack will insert the image and will also load an additional file straight from Instagram’s website, in order to display the Instagram image and all the additional Instagram features around it.

    That should work well. However, when you load more posts without actually reloading the page (like with a plugin like Ajax Load More), that additional file can’t be loaded and the image won’t appear.

    Could you try to deactivate Jetpack’s Shortcode Embeds module for a few minutes (you can do so under Jetpack > Settings > Writing in your dashboard), and then create a new post where you will post an Instagram URL on its own line, without using any shortcode, like so:

    http://i.wpne.ws/jRUy

    When adding an Instagram URL on its own line like this, you don’t need any extra plugin; WordPress itself will take care of transforming the URL into an Instagram embed.

    Publish the post, and see if it can be displayed properly. You can then change the post’s published date so it doesn’t appear on the first batch of posts that appear on your site, but only later when using the Ajax Load More plugin.

    Let me know if the problem remains then!

    • This reply was modified 9 years, 1 month ago by Jeremy Herve.
    Thread Starter sdotsamuel

    (@sdotsamuel)

    That did the trick.

    Thanks.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Excellent, I’m glad to hear it.

    You should now be able to enable the Shortcode embeds module again; as long as you use the Instagram URLs on their own line, everything should work.

    Thread Starter sdotsamuel

    (@sdotsamuel)

    As luck would have it…

    So, I deactivated Jetpack’s Shortcode Embeds module for a few hours and we were able to scroll down and see other posts and the Instagram embeds were working. We also noticed that the shortcode for Soundcloud stopped working. We assumed this was normal behavior. Then we turned the module back on. The Instagram embeds stopped working.

    Any suggestions?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Try adding the following code snippet to a functionality plugin like this one:

    
    /**
     * Remove Jetpack's Instagram shortcode.
     *
     * @param array $shortcodes Array of shortcodes enabled by Jetpack on the site.
     */
    function jeherve_remove_jp_shortcode( $shortcodes ) {
    	$jetpack_shortcodes_dir = WP_CONTENT_DIR . '/plugins/jetpack/modules/shortcodes/';
    
    	$shortcodes_to_unload = array( 'instagram.php' );
    
    	foreach ( $shortcodes_to_unload as $shortcode ) {
    		if ( $key = array_search( $jetpack_shortcodes_dir . $shortcode, $shortcodes ) ) {
    			unset( $shortcodes[ $key ] );
    		}
    	}
    
    	return $shortcodes;
    }
    add_filter( 'jetpack_shortcodes_to_include', 'jeherve_remove_jp_shortcode' );
    

    You can then enable the Shortcode Embeds module back.

    Let me know how it goes.

    Thread Starter sdotsamuel

    (@sdotsamuel)

    I installed the Code Snippets plug in.

    I added the code you sent over.

    Easy.

    As of now, the Jetpack > Settings > Shortcut Embeds is turned on.

    When I look at my site on mobile, the first article displays the Instagram embed, the Ajax Load More displays the next article and the Instagram embed does not display.

    Should I clear my cache from my host (WP Engine)? or clear my cache from Cloudflare?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    It might be good to do both.

    Let me know how it goes!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Instagram Not Loading’ is closed to new replies.