Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Frank Goossens

    (@futtta)

    hmmm … not sure I understand. can you copy-paste the code you’re using now + the two URL’s (paths) that would need to be excluded?

    frank

    Thread Starter Scott Hartley

    (@destac)

    I need to exclude 2 pages.
    however one of them can be used multiple times
    https://thearcadecorner.com/star-wars-the-old-republic/write-a-review/

    The one above can be used in multiple games so all I needed to do was use the code below to exclude it.

    As for the second URl its any BuddyPress page where the avatar is being changed.
    https://thearcadecorner.com/members/scott0407/profile/change-avatar/

    Current code
    add_filter(‘autoptimize_filter_noptimize’,’my_ao_noptimize’,10,0);
    function my_ao_noptimize() {
    if (strpos($_SERVER[‘REQUEST_URI’],’/write-a-review/’)!==false) {
    return true;
    } else {
    return false;
    }
    }

    Thread Starter Scott Hartley

    (@destac)

    I figured it out lol I am an idiot sometimes. The problem was I didn’t think about the error. It spits out an error because when I duplicated the above code it would read it and see the same filter twice but with 2 different urls so to exclude the 2 different pages I just needed to change it slighly.

    add_filter(‘autoptimize_filter_noptimize’,’second_ao_noptimize’,10,0);
    function second_ao_noptimize() {
    if (strpos($_SERVER[‘REQUEST_URI’],’/write-a-review/’)!==false) {
    return true;
    } else {
    return false;
    }
    }

    by changing the my_ao_noptimize to something else it works sorry about that.

    Plugin Author Frank Goossens

    (@futtta)

    morning destac;
    trial and error is the best way to learn my friend, trial and error! ??

    you can even simplify this by combining this into one filter;

    add_filter('autoptimize_filter_noptimize','desctac_ao_noptimize',10,0);
    function destac_ao_noptimize() {
       if ((strpos($_SERVER['REQUEST_URI'],'/write-a-review/')!==false)||(strpos($_SERVER['REQUEST_URI'],'/change-avatar/')!==false)) {
          return true;
       } else {
          return false;
       }
    }

    have fun,
    frank

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Excluding 2 different pages with API’ is closed to new replies.