Tagged: category
-
AuthorPosts
-
February 17, 2016 at 6:56 pm #584899
I’m trying to write a function that will inject specific code to disable a plugin on a specific category archive page.
`if(is_category(5405)) {
remove_filter(‘pre_get_posts’,’ksuce_exclude_categories’);
}
I can get the code to work in a page (using Code Widget in Enfold framework), but can’t get it to work in function.php or even in archive.php.February 17, 2016 at 11:29 pm #585016Hey Circle of Blue!
from functions.php to work, it has to be a function, that will hook to the wp_head and will interact with the pages.
Can u explain us why you need to move it, so we can help you out further?Cheers!
BasilisFebruary 17, 2016 at 11:57 pm #585025Sorry – that code is what I tried at the top of archive.php.
Basically, I need to be able to execute code when a category loads. I can’t use it in the category as there’s not a page to edit.
February 21, 2016 at 10:26 am #586630Hey!
Please use this in the functions.php file:
// adjust settings on init add_action('init','ava534345953_init', 50); function ava534345953_init() { if(is_category(5405)) { remove_filter('pre_get_posts','ksuce_exclude_categories'); } }
Regards,
IsmaelFebruary 21, 2016 at 7:21 pm #586729Thanks Ismael, but it doesn’t work. I tested by adding an else to the function.
I also tried using the name and slug for is_category( ) but none of them worked.
February 25, 2016 at 11:46 am #588936Hey!
remove_filter('pre_get_posts','ksuce_exclude_categories');
Where is the “ksuce_exclude_categories” function located? Is it a plugin? Please post the code on pastebin.com.
Cheers!
IsmaelFebruary 25, 2016 at 6:13 pm #589332It’s a plugin but I have realized that it will disable the RSS feed in any case, either due to a flaw in the plugin or something internal to Enfold.
I realize that it would be a lot easier to exclude through the flow of Enfold if that is possible. Is there an easy way to exclude a category except on its own category page? Thanks!
February 26, 2016 at 7:06 am #589566Hey!
I realize that it would be a lot easier to exclude through the flow of Enfold if that is possible. Is there an easy way to exclude a category except on its own category page? Thanks!
I’m sorry but I don’t understand what you’re trying to do. Could you please explain it further? If you’re trying to alter the page query, use the pre_get_posts filter: https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.