hey mate, could you also provide a second example to follow to exclude multiple pages too
that would be very helpful too
cheers Grant
Hello
We have a filter named “do_rocket_lazyload”, it returns a boolean value.
So you can do this :
add_action( 'template_include', 'wprocket_no_lazy_load' );
function wprocket_no_lazy_load() {
if ( in_array( get_queried_object_id(), array( 1, 2, 3 ) ) {
add_filter( 'do_rocket_lazyload', '__return_false' );
}
}
You can change/add/delete values from the array with 1,2,3 🙂
See you!
ok but how does it know which “single page” that I want to exclude?
I don’t quite understand, can someone from your company do this for me, i’m happy to pay what is required.
cheers Grant
The 1, 2, 3 are the ids, if you want to do this for 1 page, just use 1 id.
If you want to do this for all single pages (like posts, or pages) do this :
add_action( 'template_include', 'wprocket_no_lazy_load' );
function wprocket_no_lazy_load() {
if ( is_singular() ) {
add_filter( 'do_rocket_lazyload', '__return_false' );
}
}
but it quite useless to use the plugin now.
Try to explain more your needs, what is a “single page” if it’s not an ID?
I’m thinking I can create a template for a particular type of page, for example a gallery page, and add to the template something like:
function wprocket_no_lazy_load() {
add_filter( ‘do_rocket_lazyload’, ‘__return_false’ );
}
Then choose the created template whenever I want a page that doesn’t lazyload.
I created another page template by copying and renaming page.php in my theme directory. I retitled it:
/*
Template Name: Gallery Page
*/
…and added the filter from a support post on Rocket Lazy Loader:
<?php
/*---Don't Lazy Load---*/
add_filter( 'do_rocket_lazyload', '__return_false' );
?>
…then saved and uploaded the new template to my theme directory. WP will pick up the new template, simply choose it from the available templates in the list on the page edit screen.
Yes, this is a great solution too.
Thanks!