Sign Up for OSTraining

Welcome, Guest
Username: Password: Remember me

TOPIC: Adding filter to hide product category

Adding filter to hide product category 11 months 4 weeks ago #47085

Hi,

I would like to hide a very large unfinished product category. I'm using Woocommerce & asked Woothemes for some advice on this. They said; Hiding Product categories - Hi, Add this to your functions.php file: add_filter('woocommerce_product_categories_widget_args', 'my_custom_exclude_filter'); function my_custom_exclude_filter( $cat_args ) { $cat_args = 'number of your category'; return $cat_ar…

I then asked for some more details on where abouts I should add that filter in the functions.php file & they replied; , just make sure you add it to the end of the file above ?>

So I gave it a shot. I couldn't find any '?>', so I just added it to the end of the file. I then re-added the functions.php file to Filezilla & overwrote the original file. However, I then couldn't access my site & got this message;

Parse error: syntax error, unexpected $end in /hermes/bosweb26b/b647/ipg.rachelflute/shop/wp-content/themes/abundance/functions.php on line 158

Could anyone explain this in a bit more detail please? Am I adding it to the wrong place in the file still? Is there something else I should do? I really don't know.

I know this is more of a Woothemes issue, but when they give me answers that I don't understand I don't like to admit my ignorance & so like to try here too for a more basic explanation. Here I feel I can openly admit my ignorance!! ;-)

Thanks
Please become a member of OSTraining to reply to this post.

Adding filter to hide product category 11 months 4 weeks ago #47167

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
Hi Rachel,

You probably don't want to modify your functions.php file, but create a new one or use one that may exist in your theme template folder.

I just wrote a tutorial on using the functions.php file to make some changes, but it isn't published yet. I posted it on one of my test sites for you dashhelp.com

Let me know if that answers your question.

Cheers,
Ed
Please become a member of OSTraining to reply to this post.

Adding filter to hide product category 11 months 3 weeks ago #47778

Hi,

Thanks for that. I've just got back from vacation, so php has been putting on hold for now. I will have a look at that tutorial before long & hopefully get this solved.

Regards & thanks

rachel
Please become a member of OSTraining to reply to this post.

Adding filter to hide product category 11 months 3 weeks ago #47780

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
We also launched our WordPress intermediate course. You might want to have a look at that and see if it helps you out.

Cheers,
Ed
Please become a member of OSTraining to reply to this post.

Adding filter to hide product category 11 months 3 weeks ago #47831

Hi Ed,

I had a look at the tutorial, which explained the steps I'd taken in the past. There's just one part I'm still lost on. How do I know where the last line is or exactly where to add the new code? That seemed to be my problem in the past. I'm using the php.file in my themes template folder.

There doesn't seem to be a line there that is clearly the last line, or at least not one that is near the other lines. For example, another issue I have is configuring my Woocommerce pages. Woothemes said;

First unhook the WooCommerce wrappers;

remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);

remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);

Then hook in your own;

add_action('woocommerce_before_main_content', create_function('', 'echo "<section id=\"main\">";'), 10);

add_action('woocommerce_after_main_content', create_function('', 'echo "</section>";'), 10);

I need to figure out the ID code etc, but even if I do that, I'm still not sure exactly where to remove or add these old or new codes from? Should I go to the last line that has code on it & then add a new line just below that? Are the numbers at the start of every line relevant?

Thanks
Please become a member of OSTraining to reply to this post.

Adding filter to hide product category 11 months 3 weeks ago #47855

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
The numbers at the start of the line are line numbers for you're reference.

In the functions.php file in the template directory, there is no ending tag like the core functions.php file. So you can just go to the blank space at the end and add whatever you want.

ed
Please become a member of OSTraining to reply to this post.

Sign Up for OSTraining

Powered by Kunena Forum

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.