WordPress.org

Support

Support » Plugins and Hacks » Jetpack by WordPress.com » [Resolved] infinite scroll on home page only

[Resolved] infinite scroll on home page only

  • Trying to figure out a way to have the neverending infinite scroll be init/active on the home page only and (not) search and archive pages.

    The issue is it tries to execute on custom post type things like bbpress and other template redirect plugins where they have the archive bit set.

    So, something like this (but this doesn’t work):

    add_action('after_theme_setup', 'thistheme_remove_infinite_scroll');
    
    function thistheme_remove_infinite_scroll() {
    	if (!is_home()) {
    		remove_theme_support( 'infinite-scroll', 19);
    	}
    }

    or if someone knows where I can just remove action it from executing on anything but the home/front page

    remove_action( 'init', 'the_neverending_home_page_init', 20 );

    https://wordpress.org/plugins/jetpack/

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

    @jeherve

    Jetpack Mechanic

    Could you try to add the following code to your theme’s functions.php file:

    function tweakjp_custom_is_support() {
        $supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() );
    
        return $supported;
    }
    add_filter( 'infinite_scroll_archive_supported', 'tweakjp_custom_is_support' );

    Let me know if it helps.

    Yeap, that did the trick, stopped it from executing anywhere but the home, appreciate it.

    Now if I can figure out why the jetpack menu is visible to subscribers/contributors/editors ;/

    I realize that it’s probably meant for users to use publicize and what not, .. but nah – don’t want subscribers to even see the menu – even then not even contributors, so I was trying this:

    add_action( 'admin_menu', 'nuke_jetpack_lowlevel_menu' );
    function nuke_jetpack_lowlevel_menu() {
    	if (class_exists('Jetpack') && !current_user_can('edit_posts') ) remove_action( 'admin_menu', array( Jetpack::init(), 'admin_menu' ) );
    }

    but that doesn’t work ;/

    Plugin Author Jeremy Herve

    @jeherve

    Jetpack Mechanic

    Now if I can figure out why the jetpack menu is visible to subscribers/contributors/editors

    I realize that it’s probably meant for users to use publicize and what not

    You’re correct.

    You could try this code:

    function jp_rm_menu() {
    	if( class_exists( 'Jetpack' ) && !current_user_can( 'edit_posts' ) ) {
    
    		// This removes the page from the menu in the dashboard
    		remove_menu_page( 'jetpack' );
    	}
    }
    add_action( 'admin_init', 'jp_rm_menu' );

    No dice on the above ;/

    Just a side note, no reason for subscribers at all to see it even if it were the case for publicize – they can’t post anything anyways 😉

    And whoever hits the ‘publish’ button probably wants it to go on the network he’s associated with the site maybe? maybe current_user_can(‘publish_posts’) ? would be better?

    Plugin Author Jeremy Herve

    @jeherve

    Jetpack Mechanic

    Just a side note, no reason for subscribers at all to see it even if it were the case for publicize – they can’t post anything anyways 😉

    Subscribers cannot use Publicize, but they can use Toolbar Notifications, as well as Stats if you decide to give them access on the Stats configuration page.

    No dice on the above ;/

    Who do you want to be able to access the menu?

    • Only authors and above: publish_posts
    • Only editors and above: edit_others_posts
    • Only admins: manage_options

    I tested all 3 options, it seems to work.

    Yes, thank you; upped it to manage_options and everything is peachy keen now, I do appreciate your time on this – client is very very happy.

    – Phil

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] infinite scroll on home page only’ is closed to new replies.
Skip to toolbar