WordPress.org

Ready to get started?Download WordPress

Forums

Easy Digital Downloads
[resolved] Changing styles based on category (4 posts)

  1. awwnuts
    Member
    Posted 7 months ago #

    What I am attempting to do is add an if statement to check the category of the product, then change the border color around it based on the category.

    I do not know what command to use to get the category though?

    if($product_category == "143"){do this};

    I dont know what I need to do to set the correct variable into the $product_category.....

    I will have 3 main categories that my products fall into. They are the main parents to many sub categories.

    TLDR; What function or existing variable can I use to know my products category?

    http://wordpress.org/plugins/easy-digital-downloads/

  2. Pippin Williamson
    Pippin's Plugins and Plugin Reviewer
    Plugin Author

    Posted 7 months ago #

    You can use this:

    if( has_term( 143, 'download_category' ) ) {
        // do something
    }
  3. awwnuts
    Member
    Posted 7 months ago #

    Very cool. Works great!

    Resovled.

  4. Pippin Williamson
    Pippin's Plugins and Plugin Reviewer
    Plugin Author

    Posted 7 months ago #

    Great!

Reply

You must log in to post.

About this Plugin

About this Topic