質問

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. 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).
ライセンス: CC-BY-SA帰属
所属していません wordpress.stackexchange
scroll top