update cache with subcategory
-
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 tooThe page I need help with: [log in to see the link]
-
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.
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
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.You can use the
swcfpc_post_related_url_initfilter 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.jpegok I’m not an advanced user could you tell me how to do this because I don’t understand how to do it
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.
Thank you very much for the help and taking the time to create this code, but could you tell me where to put it?
You can put the code in the
functions.phpfile of your theme. That would be easiest for you.Thank you very much for that, I am grateful for the support and guidance in this process
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
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
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 );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 workIn 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/QbHdCq4Thats a fatal error there is definately some error log. Share a screenshot of your
functions.phpfile on how you added the code.
The topic ‘update cache with subcategory’ is closed to new replies.