Site logo

Archived topic

PHP Question

3 replies · Started by Michael on March 6, 2020

Viewing posts 1–4 of 4

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.

Hi there,

try:

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

Thank you very much David, that has fixed the errors. I appreciate it :)

You're welcome

This archived topic is closed to new replies.