3

I would like to create a blank page, which is used to list out the product by the category , so far I have found some code like this:

          $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'hot-deals');
          $loop = new WP_Query( $args );
          while ( $loop->have_posts() ) : $loop->the_post(); 

global $product; 
var_dump($product);

endwhile;
wp_reset_query();

The problems is:

1) Where should I place the code? I tried adding it in the backend->add new page, I installed some plugin that allow me to insert PHP code, tested that the code is fine.

However I would like to generate an XML from the result. If I simply create a page, it will include the header and footer in it.

How to create a blank page and at the same time can use the Classes/ functions from woocommerce?

e.g.

my-domain.com/rss

1 Answer 1

3
  1. Create a new page in /wp-admin (in the left column: Pages -> Add New);
  2. create new custom page template after reading through this doc;
  3. put your code in there;
  4. go into the page you created in #1 and assign the page template to it (in the right column, Page Attributes box, the drop-down under 'Template' - your template should be on the list, if it's not then you did something wrong in #2 - or simply didn't refresh).
1
  • page you mentioned 404s
    – Ahmed Eid
    Aug 8, 2017 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.