• Resolved osvaldo0123

    (@osvaldo0123)


    Hello, I have a small inconvenience
    if I have a category called
    Entertainment
    and subcategory called
    cinema
    music
    entertainment
    Etc.
    When I publish something in cinema the entertainment cache is not updated and vice versa too

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 35 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Yes because the system cannot understand the parent category. It only understands the category in which it article has been linked to. Unfortunately as of now, I don’t see a way around it. You can either manually purge it or select the purge whole cache option when adding/updating articles.

    Thread Starter osvaldo0123

    (@osvaldo0123)

    and if a section is placed in the plugin where the URLs that are always going to be purged can be placed , maybe like wp rocket

    Thread Starter osvaldo0123

    (@osvaldo0123)

    In my case I cannot clear the global cache, I have more than 12 thousand posts and that would imply damaging the performance of my website,
    If something like the aforementioned could be implemented, it would be excellent since it would only be placed, for example, https://elprofeshow.com/category/(*) and all the categories or links that exist in the section would be deleted.

    Plugin Contributor iSaumya

    (@isaumya)

    You can use the swcfpc_post_related_url_init filter to pass a list of URLs that you would like to be considered in the related URL list. It’s mentioned in the FAQ tab of the plugin settings: https://i.imgur.com/p6WNiMg.jpeg

    Thread Starter osvaldo0123

    (@osvaldo0123)

    ok I’m not an advanced user could you tell me how to do this because I don’t understand how to do it

    Plugin Contributor iSaumya

    (@isaumya)

    You basically have to send an array of the URLs that you also like to be part of related URLs when you add/update post:

    <?php
    add_filter( 'swcfpc_post_related_url_init', function( $listofurls, $postId ) {
    	// Some items that will always be added to the related listofurls
    	$listofurls = [ 
    		get_home_url( null, '/category/entertainment/' ), 
    		get_home_url( null, '/category/some-category/' ),
    		get_home_url( null, '/category/some-other-category/' )
    	];
    
    	return $listofurls;
    } );

    Here is an example code of adding couple of category pages.

    Thread Starter osvaldo0123

    (@osvaldo0123)

    Thank you very much for the help and taking the time to create this code, but could you tell me where to put it?

    Plugin Contributor iSaumya

    (@isaumya)

    You can put the code in the functions.php file of your theme. That would be easiest for you.

    Thread Starter osvaldo0123

    (@osvaldo0123)

    Thank you very much for that, I am grateful for the support and guidance in this process

    Thread Starter osvaldo0123

    (@osvaldo0123)

    Excuse me, can I increase the cache clearing time? I mean going from 10 seconds maybe to a little more every 10 minutes or something like that

    Thread Starter osvaldo0123

    (@osvaldo0123)

    I had no luck with the code above when I post something at the time of posting my website crashes and I try to update the post and everything seems fine but the purge didn’t work

    Plugin Contributor iSaumya

    (@isaumya)

    Hi,
    first of all I don’t understand what you mean by website crashes – it the site is throwing a error 500 then in the PHP error log there should definitely be some log.
    Can you show me how you added the code? I mean can you share screenshot or screen recording?

    can I increase the cache clearing time?

    – What cache clearing time? Sorry I do not understand. You can use any of these constants (https://i.imgur.com/tRxzTQ6.jpeg) to make these changes. Like adding a define statement in yourwp-config.php`.
    E.g. define( 'CONSTANT_NAME', VALUE );

    Thread Starter osvaldo0123

    (@osvaldo0123)

    Thanks again, I was able to place the place this
    define statement in yourwp-config.php`.
    E.g. define( ‘CONSTANT_NAME’, VALUE ); and i think it has to work

    In this image I leave the error when placing the code in functions.php in the php log nothing appears with reference to this
    https://ibb.co/QbHdCq4

    Plugin Contributor iSaumya

    (@isaumya)

    Thats a fatal error there is definately some error log. Share a screenshot of your functions.php file on how you added the code.

    Thread Starter osvaldo0123

    (@osvaldo0123)

Viewing 15 replies - 1 through 15 (of 35 total)

The topic ‘update cache with subcategory’ is closed to new replies.