WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Show only specific Product Categories on homepage (15 posts)

  1. Konevo
    Member
    Posted 1 year ago #

    This seems to have been covered in bits in the past but I can't find a full explanation for this particular problem.

    I'm using WooCommerce with the Mystile theme, and I'm trying to find the simplest and most efficient way to show ONLY TWO of the main categories on the homepage. So I either need to find a way to hide all the other categories AND subcategories, or code to show only categories 20 and 21 (these are the category IDs)

    I started by trying to find out how to disable the subcategories but the only info I can find on this is from earlier versions of WooCommerce e.g. http://www.skyverge.com/blog/hide-certain-woocommerce-subcategories-catalog/

    I have also been looking at how to exclude categories using wp_list_categories but I'm not sure if I can transfer the categories-template.php to a child theme, or even if I need to. I'm also not sure that's the most efficient solution to the problem, especially as we may be adding more categories and subcategories in the future which will also need to be hidden.

    Can anyone provide a solution?

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

  2. droolo
    Member
    Posted 11 months ago #

    Hello, I think that I have the solution.

    Modify in "theme-woocommerce.php" file (in themes\mystile\includes) the line 651:

    echo do_shortcode('[product_categories number=""');

    Option 1 - if you like to show only the main categories:
    echo do_shortcode('[product_categories number="" parent=0');

    Option 2 - if you like to show only some ids:

    echo do_shortcode('[product_categories number="" ids="20,21"');

    Please test it and give me your feedback.

    (Sorry for my english)

  3. daileycon
    Member
    Posted 11 months ago #

    No. Look at update 1.2.14, it's filter able, no edit required

    http://www.woothemes.com/changelogs/mystile/changelog.txt

  4. 3enjdw
    Member
    Posted 11 months ago #

    Hello this is something I need - please does anyone know how to apply the filter?

  5. daileycon
    Member
    Posted 11 months ago #

  6. 3enjdw
    Member
    Posted 11 months ago #

    thanks for reply. I did already find this and try it in wp-content/themes/mystile/functions.php but got no joy.

    Changing the home page to a static page in /settings/reading and then using [product_categories number="" parent="0"] almost gets me what I want but it bugs me that i cant get it going....

  7. daileycon
    Member
    Posted 11 months ago #

    Have you added a support ticket to the Mystile developer? I have sent requests all the time and he gets it done (star rating, remove twitter, etc). If you do contact him, tell him to add captcha to the contact for like Canvas uses!

  8. 3enjdw
    Member
    Posted 11 months ago #

    I will have a another look today and contact div if I need to. Will post a solution here if I find one/get given one. Thanks for input :)

  9. daileycon
    Member
    Posted 11 months ago #

    This might be a dumb question but in Mystile theme options under Layout Options it has an area for

    Specify a comma seperated list of category IDs or slugs that you'd like to exclude from your homepage (eg: uncategorized).

    You did try this right?

  10. 3enjdw
    Member
    Posted 11 months ago #

    I did see that thanks. However I am currently populating and controlling the stock levels shop(s) using csv import plugin, and this import will eventually be automated. To then have to go in and tidy the categories from the front page of each shop is kind of out the question... I realise that I am getting into the realms of a bespoke/theme perhaps but the mystile theme ticks so many boxes.

  11. Stefan
    Member
    Posted 9 months ago #

    Hi,

    Did you managed to get this solved, I am in the exact same position as you, mystyle with woocommerce and an automated product importer. I just want to display certain categories on a page and the shortcode Product_categories with the argument ids does not work.

    Thanks.

  12. atesdanis
    Member
    Posted 7 months ago #

    1) edit this file theme-woocommerce.php (includes/theme-woocommerce.php)
    2) find it "function mystile_product_categories() {"

    3) copy these lines

    add_filter( 'mystile_homepage_product_categories_params', 'homepage_parent_categories_only' );
    function homepage_parent_categories_only( $params ) {
        $params = 'parent="0"';
    	return $params;
    }

    4) paste it after line that you found in item 2
    5) Save

  13. goLeader
    Member
    Posted 5 months ago #

    @atesdanis ... Perfect, it works!

    Paste code JUST BELOW of "function mystile_product_categories() {"

    Thanks again !

  14. smalik
    Member
    Posted 5 months ago #

    hi,
    i m a newbie to wordpress and i dont know about codes as well.

    i have a kind of same problem but i want a code and a way to hide some of the catagories from my mystyle homepage.

    i am using mystyle theme
    i want to know in which file i will add code?
    where exactly?
    i noticed mystyle theme-functions.php have some code for exclude catgories but i dont know where should i put the ID of catagories.

    please can someone help?

  15. kdelaney1@gmail.com
    Member
    Posted 5 months ago #

    @atesdanis Thank You - your solution worked for me as well!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic