WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
[resolved] infinite scroll on home page only (7 posts)

  1. Frumph
    Member
    Posted 6 months ago #

    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/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 6 months ago #

    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.

  3. Frumph
    Member
    Posted 6 months ago #

    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 ;/

  4. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 6 months ago #

    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' );
  5. Frumph
    Member
    Posted 6 months ago #

    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?

  6. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 6 months ago #

    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.

  7. Frumph
    Member
    Posted 6 months ago #

    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

Reply

You must log in to post.

About this Plugin

About this Topic