• Resolved RobotFX

    (@wattaman)


    Hi,

    I’m using this plugin and I had to add the rewrite rules in the nginx config file for it to work properly. So far so good.
    However, I have another sitemap (address is googlecatalog.xml) that now doesn’t load in the browser (404 error). Should I use another rewrite rule for this custom sitemap? Which is it?

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • add_rewrite_rule( string $regex, string|array $query, string $after = ‘bottom’ )
    function add_rewrite_rule( $regex, $query, $after = ‘bottom’ ) {
    global $wp_rewrite;

    $wp_rewrite->add_rule( $regex, $query, $after );
    add_action( ‘init’, function() {
    add_rewrite_rule( ‘myparamname/([a-z0-9-]+)[/]?$’, ‘index.php?myparamname=$matches[1]’, ‘top’ );
    } );
    add_filter( ‘query_vars’, function( $query_vars ) {
    $query_vars[] = ‘myparamname’;
    return $query_vars;
    } );

    add_action( 'template_include', function( $template ) {
        if ( get_query_var( 'myparamname' ) == false || get_query_var( 'myparamname' ) == '' ) {
            return $template;
        }
     
        return get_template_directory() . '/template-name.php';
    } );
    Thread Starter RobotFX

    (@wattaman)

    thanks, but I don’t know what to do with the code. Maybe you can elaborate?

    Thanks for reaching out to us. Yes, you can try adding a rewrite rule for the custom sub-sitemap you created. Moreover, If you’re comfortable, then please provide us with the sitemap URL and rewrite the rule you are using currently.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sitemap rewrite rules for custom products’ is closed to new replies.