• Resolved Thomas McMahon

    (@twistermc)


    I’d like to disable the AMP feature on posts tagged with quiz. I want to do this because AMP pages do not work with the quiz.

    Is there a function that I can run to disable AMP based on tag?

    I’ve seen this question asked many times, but I haven’t found any good clear answer.

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • 
    add_filter( 'amp_skip_post', 'twistermc_amp_skip_quiz_posts', 10, 3 );
    
    function twistermc_skip_amp_post( $skip, $post_id, $post ) {
        if ( has_tag( 'quiz', $post_id ) ) {
            $skip = true;
        }
    
        return $skip;
    }
    
    Thread Starter Thomas McMahon

    (@twistermc)

    Thank you!!

    teelanovela

    (@teelanovela)

    Hello! I have the exact same issue. The filter looks great but when I insert it I get the following error. Any idea what causes that?

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'twistermc_amp_skip_quiz_posts' not found or invalid function name in /home/.../public_html/wp-includes/plugin.php on line 235

    Thanks

    teelanovela

    (@teelanovela)

    I managed to get it to work with the following code:

    add_filter( 'amp_skip_post', 'skip_quiz_posts', 2 );
    
    function skip_quiz_posts( $skip ) {
        if ( has_tag( 'quiz', get_post( $post_id ) ) ){
            $skip = true;
        }
        return $skip;
    }
    roxer82

    (@roxer82)

    I am having the same issue. In which file and where should I add that code?

    teelanovela

    (@teelanovela)

    @roxer82 just drop it in your theme’s function.php

    roxer82

    (@roxer82)

    Thank you very much!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Function to disable AMP on specific post’ is closed to new replies.