• Hi,
    I am searching for a solution to disable the AMP on all the categories except one category… I know I can go AMP – Settings – Tools to disable the AMP on Specific Categories but I am looking for opposite solution enable the AMP only on ONE Category.

    We have over 80 categories so looking to find a hook/function to enable the AMP only one category instead of disabling 79 categories.

    Any help in this case???

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    You can achieve it by following the below option. Please refer to the below screengrab and let us know back if you need further assistance.

    Reference screengrab:https://prnt.sc/1s64myj

    Thread Starter wpninja3

    (@wpninja3)

    Thanks for the reply but sorry to say you did not even read my message “I am looking for opposite solution enable the AMP only on ONE Category. We have over 80 categories so looking to find a hook/function to enable the AMP only one category instead of disabling 79 categories.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    We have this option, But due to some bug, it’s not working properly. For this, We have raised a GitHub ticket in our repository. Our developer will work on it and fix it in the next updates.

    For reference please track the following ticket: https://github.com/ahmedkaludi/accelerated-mobile-pages/issues/5139

    Thread Starter wpninja3

    (@wpninja3)

    Okay thanks Ahmed

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    You’re welcome, We are working on it and get back to you soon with an update.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    We have created a filter for you and with the help of the below code you can remove the AMP on all the categories except one

    add_filter(‘ampforwp_skip_category’ ,’prefix_skip_category’);
    function prefix_skip_category($skip){
    $cat_id = get_the_category();
    //AMP will only work on sports category
    if($cat_id[0]->name != ‘sports’){
    $skip = true;
    }
    return $skip;
    }`

    You just need to remove the sports from the code and replace it with the name of the category you want to show AMP.

    Please do that and let us know

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Disable AMP for All Except One Category’ is closed to new replies.