Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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.

    #585016

    Hey 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!
    Basilis

    #585025

    Sorry – 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.

    #586630

    Hey!

    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,
    Ismael

    #586729

    Thanks 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.

    #588936

    Hey!

    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!
    Ismael

    #589332

    It’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!

    #589566

    Hey!

    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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.