Well, sometimes I just don’t look long enough…
I found the file and code at /inc/class-custom-sidebars-replacer.php
around lines 200-400.
For posts (is_single()
) you go through 4 steps, 1.1 to 1.4, lines 208 to 277. Step 1.3 checks for categories.
For pages, on step 5, it’s only 3 steps, excluding the category one (lines 361 to 426). The rest is fairly similar to the posts. I now just copied step 1.3 and pasted it as ‘5.25 CUSTOM’ in between 5.2 and 5.3 and it all works!
I still got a little help request though: How do I store those changes save now; without getting replaced with your next plugin update?
Thanks for your help!
The copied code:
// 5.25 CUSTOM If no metadata set then use the category settings.
if ( $replacements_todo > 0 ) {
$categories = self::get_sorted_categories();
$ind = sizeof( $categories ) -1;
while ( $replacements_todo > 0 && $ind >= 0 ) {
$cat_id = $categories[ $ind ]->cat_ID;
foreach ( $sidebars as $sb_id ) {
if ( $replacements[ $sb_id ] ) { continue; }
if ( ! empty( $options['category_single'][ $cat_id ][ $sb_id ] ) ) {
$replacements[ $sb_id ] = array(
$options['category_single'][ $cat_id ][ $sb_id ],
'category_single',
$sidebar_category,
);
$replacements_todo -= 1;
}
}
$ind -= 1;
}
}
Hi Jan,
Hope you’re doing well š
Glad to see you’ve managed to find a solution.
However, I’m afraid that there’s no workaround for this without actually modifying the plugin core files.
I will forward these nice steps that you provided to our devs so they can check it out and see if it’s something that could be added in future versions of the plugin.
Cheers,
Predrag
Hi Predag,
alright, I wont update the plugin then. Or copy it in there again manually.
Do you think you could update me (here or per email) if you integrate the functionality?
Thanks,
Jan
Hey @rumpel2116,
Hope you’re well.
We can update this thread if we add this feature to next updates, I am adding notes about that into the report that Predrag created. But until that time if you want to use it you should continue with your own custom codes. Unfortunately, there is no feature in WordPress that can save your custom changes at plugin updates. You need to do same custom implementations when plugin updated.
Cheers,
Oguz
Just to say that this is exactly what I am looking for as well.
Hi there!
Any news on this one? I fear I will update it sometime because I forget about the custom code… Just those few line changes provided, please š
Thanks,
Jan
Hey @rumpel2116,
Hope you’re well.
I am afraid it’s not published yet. But we are in the testing phase for that, so it will be included soon. Thanks for your patience!
Cheers,
Oguz
You fixed this with the latest update (3.2.0), thanks a lot! Works perfectly.