• I want the sitemap to only show
    products and categories that are available to the current user.
    Furthermore, to show only categories, that have actual products in them.

    Is that possible?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter darkallman

    (@darkallman)

    Since I dont see an exclude function for Woocommerce product categories, I solved it by adding

    if(in_array($product_category->term_id,array(238))){
    	continue;
    }

    For products I added:

    			<?php 
    			while ( $loop->have_posts() ) : $loop->the_post(); 
    				
    			$post_id = get_the_ID();
    			$post = get_post( $post_id );
    			$product = wc_get_product( $post_id );
    			if($product->is_visible() && empty($post->post_password)){			
    			?>
    
    				<li><?php the_title( '<a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a>' ); ?></li>
    
    			<?php 
    			}
    			endwhile;
    			?>

    This will hide not visible products and password protected posts.
    Maybe you can add it.

    Plugin Author omsuhani

    (@omsuhani)

    i have resolved you problem password protected product restrict to display in sitemap

    thank for suggestion

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show only public available posts’ is closed to new replies.