• Resolved wp-anis

    (@anis1287)


    Hi,

    Thanks again for your plugin.

    I would like to preload some stuffs on specific pages. I found your php code on another post.

    ————————————————————————————-
    add_filter( ‘autoptimize_filter_extra_tobepreloaded’, ‘frontpage_specific_preload’ );
    function frontpage_specific_preload( $preload_array ) {
    if ( is_front_page() ) {
    $preload_array[] = ‘https://staging.tripletsmum.com/wp-content/uploads/2017/11/Naming-Triplets.jpg’;
    }
    return $preload_array;
    }
    ——————————————————————————-

    But this is specific to the front page. I’m not very advanced at this point in wordpress specific coding.

    I tried is_page(‘page title or ID’) on the condition, but this doesn’t seems to work.

    Any help on this would be appreciated. Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    might be an issue of quotes, try
    $preload_array[] = 'https://staging.tripletsmum.com/wp-content/uploads/2017/11/Naming-Triplets.jpg';

    alternatively you could work with a condition like

    
    if ( strpos( $_SERVER['REQUEST_URI'], '/preload/on/this/page' ) !== false) {
        $preload_array[] = 'https://staging.tripletsmum.com/wp-content/uploads/2017/11/Naming-Triplets.jpg';
    }

    to add the preload on https://yoursi.te/preload/on/this/page

    hope this helps,
    frank

    Thread Starter wp-anis

    (@anis1287)

    Thank you very much.

    to preload multiple elements?

    It seems separating elements with comma is not working.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    as it concerns an array, you’ll have to add them one by one;

    $preload_array[] = 'https://staging.tripletsmum.com/wp-content/uploads/2017/11/Naming-Triplets.jpg';
    $preload_array[] = 'https://staging.tripletsmum.com/wp-content/uploads/2017/12/another.jpg';
    $preload_array[] = 'https://staging.tripletsmum.com/wp-content/uploads/2017/12/third_one.jpg';
    Thread Starter wp-anis

    (@anis1287)

    Thank you very much.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome, feel free to leave a review of the plugin and support here! ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘preload on specific pages’ is closed to new replies.