[Resolved] PHP Question

Home Forums Support PHP Question

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1187167
    Michael

    Hi guys,

    I’ve been sent a code snippet from RankMath but unfortunately it errors. I tried adding extra } but this didn’t help. I’ve also written to RankMath but their response rate/time is not all that good, which means I will be sitting twiddling my thumbs till Monday trying to work it out. I wondered if would please be so kind as to cast your expert eye (or eyes ;)) over the code to see what syntax is not right?

    add_filter( 'rank_math/sitemap/exclude_post_type', function( $exclude, $type ){
        if ( $type === 'ec-product' ) {
             return false;
        }
     
        return $exclude
    }

    These are the errors:

    https://www.dropbox.com/s/8r55fgivt99xmwk/snippet-errors.jpg?dl=0

    Thank you very much for your help as always.

    Michael.

    #1187184
    David
    Staff
    Customer Support

    Hi there,

    try:

    add_filter( 'rank_math/sitemap/exclude_post_type', function( $exclude, $type ){
        if ( $type === 'ec-product' ) {
             return false;
        }
        return $exclude;
    });
    #1187256
    Michael

    Thank you very much David, that has fixed the errors. I appreciate it ๐Ÿ™‚

    #1187352
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.