• Hello. I have been trying to display my products by categories. Basically I want to have a page or a section on a page to display “mens green socks” and another to display “mens blue hats”. I have product categories set up for mens, green, blue, socks, and hats I am using the following code in a [insert_php][/insert_php] block (I have installed a plug in that says it allows php to be used using that statement) but all I get is a blank page

    > is being auto changed to >

    $args = array(
    ‘posts_per_page’ =>; -1,
    ‘tax_query’ =>; array(
    ‘relation’ =>; ‘AND’,
    array(
    ‘taxonomy’ =>; ‘product_cat’,
    ‘field’ =>; ‘slug’,
    ‘terms’ =>; ‘massachusetts’
    ),
    array(
    ‘taxonomy’ =>; ‘product_cat’,
    ‘field’ =>; ‘slug’,
    ‘terms’ =>; ‘mens’
    ),
    array(
    ‘taxonomy’ =>; ‘product_cat’,
    ‘field’ =>; ‘slug’,
    ‘terms’ =>; ‘tanks’
    )
    ),
    ‘post_type’ =>; ‘product’,
    ‘orderby’ =>; ‘title’,
    );
    $query = new WP_Query( $args );

Viewing 1 replies (of 1 total)
  • Hi there,

    Is this the exact PHP code snippet you used?
    Because the arrows in the array say: “=>;” (the semicolon here is not valid PHP).

    Hope this helps, because the intended query seems to be correct.

Viewing 1 replies (of 1 total)
  • The topic ‘coding an array for my product pages’ is closed to new replies.