[Plugin: Content Aware Sidebars] Sidebar not working with custom post type
This is a great plugin that has worked perfectly until just recently when we started using the All in one event calendar plugin. It seems as if the custom post taxonomies are not being seen by CAS. Only the default sidebar will appear on our event posts. I’ve been through the setting multiple times to assure all is well there. I noticed the post by Marfarma regarding “Custom Post Types not seen when created by plugin”, but we’re using V0.7, so I’ve discounted there being a problem there. Could the confusion be related to our event template being named single-ai1ec_event.php? I’m probably reaching for straws with that idea. Obviously, I could use your insight. Any direction that you could provide would be greatly appreciated!
Thanks for your feedback. The plugin does support custom post types and taxonomies, but the deal is, that even though the plugin is set to be loaded very late in order to support other plugins introducing custom post types and taxonomies, some plugins might be loaded even later. I’m not sure if this makes sense to you, and I don’t know if that is the problem in this case, but it is the first thing that crossed my mind.
Does the custom post type and custom taxonomy appear in the sidebar editor? If not, the problem is probably caused by what I mentioned before.
I’ll look into the issue later and try to reproduce it, but I am pretty sure that your template name has nothing to do with it.
Thanks for the reply Joachim! I don’t have a full understanding of the loading process, but I get the concept. That’s what Marfarma’s post was referring to, isn’t it? I can see where that could cause a problem.
The CPT post and taxonomy all appear in the sidebar editor…hang on, I just tried selecting the event post itself from the sidebar editor list and that worked! (Sorry, I should have tried that prior to posting so that you could have all the facts.)
That definitely gets me out of a bind, but having to go in and select each post isn’t as convenient as selecting a category or tag. So with this information in hand, what do you think? Could this be a loading order problem? And if so, how could I go about fixing that?
Thanks for all your help!
I just reread the post you are referring to, and yes it is what he refer to, however, the problem back then was that I’d made it impossible for any custom post type or taxonomy to be loaded before this plugin. Of course this was fixed.
I have unfortunatly not been able to reproduce your problem with the newest version of All-in-one Event Calendar. When you are in the sidebar editor, the following three meta boxes will appear when using All-in-one Event Calendar: Events (middle), Event Categories (side) and Event Tags (side).
In the Events meta box you can choose what specific events the sidebar should be shown with or tick “Show with All Events” to show the sidebar with all events.
Have you tried “Show with All Events”?
In the Event Categories meta box you can choose what events containing specific event categories the sidebar should be shown with or again tick “Show with Event Categories” to show the sidebar with events containing any event categories. It is the same concept for Event Tags.
Have you tried “Show with Event Categories” or “Show with Event Tags”?
I did find a bug though. If you have picked custom taxonomies for the sidebar, you cannot remove them all again. I’m not sure if this is what is causing your problems, but it is of course fixed in the next version.
If none of the things I’ve suggested work, I’m pretty much out of good ideas. Could be other plugins that somehow cause the trouble. It shouldn’t be a loading order problem though, as you’ve confirmed that the meta boxes do appear in the sidebar editor.
Was just running debug and recieved this message: Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/—/public_html/wp/wp-content/plugins/content-aware-sidebars/content-aware-sidebars.php on line 410
Does that shed any light on things?
Regarding your last post:
Selecting a category or tag, show with all categories or show with all tags has no effect on sidebar.
Select the individual event in the event metabox or show with all events and the sidebar works.
Just to be clear, sidebars work flawlessly with Posts and Pages. This issue only occurs with the custom post type generated by All in one events calendar
Thanks for all your insight, hope the error message noted above helps to narrow this down.
A quick off topic question.. In the All Posts view, is it possible to have a column that shows which sidebar is assigned to the post, page, etc..?
Thanks for the debugging. What your warning say is that 1) the host sidebar you’re trying to merge with does not exist (in the database) or 2) the host sidebar is simply not an array (which it really ought to be).
I have been able to reproduce your bug under the following circumstances:
1. Clear all instances of widgets and sidebars in the database
2. Create new content aware sidebar that merges with host (sidebar-1) from the top
This will give the following notice and warning:
Notice: Undefined index: sidebar-1 in ... on line 410 Warning: array_merge() [function.array-merge]: Argument #2 is not an array in ... on line 410
However, this error will dissappear when you add a widget to any of your sidebars, as this would create an instance in the database again. This shouldn’t be the cause of your problem.
1. Create a content aware sidebar (1) with some random host
2. Create another sidebar with (1) as a host, merging with it from the top.
3. Remove sidebar (1)
4. Remove all inactive widgets belonging to (1) and add a widget to a random sidebar (to update the database)
This will give the same errors as above, only with another sidebar id. It is more likely that this might be your issue. However, the error is only reproduced ca. 1/2 times and I can’t really see how this is what is causing your problem as there – as far as I can see – is no difference in selecting Events or Event Tags/Categories for the specific sidebar.
IF this is the problem, I suggest that you check that your host sidebar exist and that you drag and drop some widgets around in order to update the databsae correctly.
About your other question, I have thought about adding the selected rules to the overview before, but I haven’t found out how to show them in a clear way yet. It is definitely a good suggestion though.
I’m having the same issue. Just reverted to 0.7 and this fixes the issue.
Custom post types made using the Custom Post Types plugin work fine, but events from the Event Manager plugin cause one sidebar being shown incorrectly when a condition for another sidebar is true.
One sidebar should only merge below secondary aside on the front page but is now shown on single event pages where conditions for another content aware sidebar are true.
The changelog might suggest:
Added: some rules are dependent of each other if present
Is causing issues? Of course the order of plugin calls might also cause problems.
Thanks for your feedback. The warning I reproduced for @coloradoouting should’ve been fixed in 0.8, so at least this is not the actual problem.
Also, you’re not using the same event plugins (All In One Event Calendar and Event Manager) and I wasn’t able to reproduce the custom taxonomy problems that @coloradooutin had.
I’ll see if I can reproduce what you’re experiencing, but I’ll be rather busy in the next couple of weeks, so I can’t say when.
The addition you refer to could be what is causing the trouble, since it works for you in 0.7. If it is, it means that I haven’t tested it thoroughly enough 🙁
The feature means that if you’ve selected both “Show with all <post type>” and an specific author, the sidebar will only be visible with the singulars that are written by that author AND are of that post type.
Before 0.8, selecting the same thing would mean that the sidebar was shown with the singular of that post type OR the singular made by that author.
I know this would definitely cause some users’ existing sidebars to behave differently after the update, but at the same time this dependency makes content aware sidebars even more flexible.
Note that not all rules are dependent yet, I think I’d only made it for post types, authors and page templates. If I get lots of complains about this, I’d consider to change it back.
Hi again. I just did a quick check and indeed there was a bug causing all post types with taxonomies to get wrong sidebars. And it was because of the new dependent rules. Taxonomies don’t make use of these new rules yet, that’s why it caused some trouble. Stupid errors like this really should be caught in the tests I do before release. I’m sorry about that!
I’ll release 0.8.2 in a minute, which fixes it.
I still haven’t been able to find the cause of Mike’s problems yet though.
Sorry for bumping this old thread. Just updated to 1.0 and it seems that you now fully rolled out the AND rule, as indicated in the changelog:
Fixed: all present rules now dependent of each other
One sidebar is used for:
Custom post type Company
Custom post type Job
Event category Career
Post category Career
Exposure Singular & Archives
Now none of this should be causing issues, since there are never two rules applicable at the same moment. However, still the sidebar only on some occasions (even for some companies it does, while for others it doesn’t).
Could you please check the code or otherwise roll back the OR function? It is too cumbersome for us to make sidebars separately for each of these rules.
Thanks a lot for your great work!
Thanks for the feedback. All rules are dependent of each other, when present in the content, yes. This means that Pages will not be influenced by Taxonomy rules (even if set in a sidebar), as they don’t support any. Custom Post Types supporting (any) taxonomies will be influenced – my guess is that’s why you now see another result for your sidebar settings.
This was done by design and is not a bug, though I do know that it might cause some UX problems when upgrading from an earlier version.
Now, I’ve thought a lot about this – also before releasing version 1, and I know that though the rules can now be displayed with a combination of specific content (which I have aimed for), it has caused some limitations as well. These limitations can be removed in several ways, where I have boiled the best solutions down to:
1) Add a “dependency” setting, letting users decide whether their rules should be dependent or not.
2) “Group” rules together and let sidebars contain several “rule groups”.
Even though I’d have to change a lot to implement both of these, 1 is the easiest, but might be the worst of them if comparing their performance. For 2 to happen, I’d say that the core of the plugin would have to be totally rewritten.
I’m liking the idea of 1 more and more, but tell me what you think. Users’ feedback mean a lot for the development of this plugin, and without it, it’s quite hard to make any decisions when knowing that it might make some users frustrated, but without knowing how big the group of excited users will be.
Still, I think the ‘discussion’ is twofold:
– Dependency of rules (which should not be an issue on our site), whether this is desirable or not.
– We aim to use one sidebar on multiple post types, and for some post types (events and posts) only if a certain taxonomy (event category and category respectively) is chosen. I guess that somewhere in the plugin, the taxonomy requirements get mixed up, since of course a certain event (or company) can never fulfil taxonomy rules on taxonomies the post type does not support. Could you recheck how the plugin deals with multiple taxonomies, each for different post types?
I agree that when a post type supports e.g. two taxonomies and both taxonomies have a rule, that both rules should be satisfied for the sidebar to show (dependency setting). However, on our site only one taxonomy is applicable at each moment.
Thanks for the quick response.
This might be a bug, however, do Company or Job support any taxonomy type? If they do, that is the reason.
When handling the taxonomies, the following is done in the code:
Does this content support taxonomies, if yes, which, if no, stop.
Does this content have any terms of the supported taxonomies, if yes, which, if no, stop.
Sidebars containing either no taxonomy rules, the taxonomies or the terms (while complying with the other content rules) are pulled from the database.
This means that if the current content, e.g. post of type Job or Company, have any taxonomies/terms, and these are not set in the specific sidebar rules, the sidebar will not be shown.
The plugin do not know how content are related to each other, but simply use procedures like the abovementioned. Sure, it would be better to relate content properly, but I’ve not come to an efficient solution on how to do this while keeping all the data in the post_metadata table.
Taxonomies are, sadly, not dependent of each other yet. This feature will definitely come some day though.
Your reply has allowed me to isolate the ‘bug’.
If I abstain from using taxonomy rules, indeed the sidebar shows with custom post types Company and Job (which support taxonomies but with no sidebar rules set on them).
However, if I then add a taxonomy rule on another post type Event (e.g. only show sidebar with events of event category Career), the sidebar disappears from Company and Job pages. Moreover, it doesn’t show on Event pages with the appropriate event category.
And it shows up again on Company and Job archive pages… And randomly on some single Company pages?
I’ve not been able to find for which companies it shows and for which it doesn’t…
The first thing is by design, as explained in the previous post. The reason for second thing happening – why the sidebar will not show on the event pages with the specified event category – is that you, I assume, tell the sidebar to be shown with: All company pages, All Job pages and event category Career. As the rules are dependent, the content will have to meet these exact rules. That is, a company page or a job page with the event category Career.
Logically, this cannot ever be met, but the plugin does not know that – it only does what you tell it to do.
As e.g. taxonomies and post types are not dependent of each other in the archive pages, the rules are not dependent here.
I cannot explain why the sidebar is shown on some specific company pages. What are the supported taxonomies for this post type?
- The topic ‘[Plugin: Content Aware Sidebars] Sidebar not working with custom post type’ is closed to new replies.