• Hello,

    I would like to include content from a post displayed above my products pages.

    I put the following code into my archive-product.php file, which I copied into my child-theme (using Twenty Twelve).

    <?php
    global $more;
    $more = 0;
    query_posts('cat=37');
    if(have_posts()) :
    while(have_posts()) :the_post();
    ?>
    <h2><a>"><?php the_title();?></a></h2>
    <div><?php the_content('Read More') ?></div>
    <?php
    endwhile;
    endif;
    wp_reset_query();?>

    As you know, this is displaying the content of the post from a particular category.

    But here is the issue.

    I want each of my product pages to display content from a different post/different category.

    In Woocommerce, I created my categories: Mens (parent), Boots, Shoes etc. as children.


    Then using the Appearance > Menu, I inserted the categories creating the pages on my site.

    Then I went into Posts > Categories and created new categories eg; mens-featured which as an id of 37.

    So I want to have the mens-featured post appear on my Mens page, boots-featured appear on my Boots page etc.

    Hope that is clear… I’m a newbie!

    I’m running a local install, but could put the site live if you would like to view the site?

    Thanks
    Joe

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter joecoll

    (@joecoll)

    Anyone got any ideas please?

    Even a quick nod in the right direction would be mich appreciated.

    Thanks
    Joe

    Plugin Contributor James Koster

    (@jameskoster)

    In your archive-product.php (or better still, hooked in via a custom function) you’ll need to query the category and then change the ID based on that.

    You can use is_tax (http://codex.wordpress.org/Function_Reference/is_tax) to check which product category is being viewed. The product category taxonomy is product_cat.

    So you’d check that the product_cat is Men’s and then set the $id as 37. And so on, for each category.

    Thanks

    Thread Starter joecoll

    (@joecoll)

    Thanks a mil James, will give that a go!

    J

    Thread Starter joecoll

    (@joecoll)

    Sorry James, but could you please provide the basic code for what you described?

    Spent the last hour trying to figure this out but I’m getting nowhere.
    I’m pretty new to this.

    Appreciate the assistance.

    Joe

    Thread Starter joecoll

    (@joecoll)

    Is this anywhere close?

    <?php
    is_tax( $product_cat, $37 );
    if(have_posts()) :
    while(have_posts()) :the_post();
    ?>
    <h2><a>"><?php the_title();?></a></h2>
    <div><?php the_content('Read More') ?></div>
    <?php
    endwhile;
    endif;
    wp_reset_query();?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Woocommerce: Post above products pages’ is closed to new replies.