Author taxonomy / select output
- This topic has 11 replies, 2 voices, and was last updated 3 years, 3 months ago by
Long Nguyen.
-
AuthorPosts
-
January 12, 2022 at 8:44 PM #33185
vacdk
ParticipantHi
I'm using the MB views to get taxonomy or a Select field with multiple from authors
{% for item in author.user_select_certifikat %}
{{ item.label }}
{% endfor %}But I have found an error or something.
When the MB views are getting output, it works fine, but only if an author have created one or more post!
If the author have not created a post, then I'm getting this error:Warning: array_merge() [function.array-merge]: Expected parameter 1 to be an array, null given in /wp-content/plugins/mb-views/src/Renderer/User.php on line 15
Can you please fix, so the author does not have to create a post to work 🙂
Regards
January 12, 2022 at 9:17 PM #33187Long Nguyen
ModeratorHi,
You can check the field value is not empty before using the loop.
{% if author.user_select_certifikat is not empty %} {% for item in author.user_select_certifikat %} {{ item.label }} {% endfor %} {% endif %}
January 13, 2022 at 2:33 AM #33196vacdk
ParticipantHi
Thanks for your reply,
Its not because the value from the term/select box is missing.
The error will come if the author have yet not created a post in a cpt.
January 13, 2022 at 10:24 PM #33209Long Nguyen
ModeratorHi,
Can you please share the PHP code that creates the fields on your site? And some screenshots of the View editor.
January 13, 2022 at 10:48 PM #33211vacdk
ParticipantHere is a video showing..
https://1drv.ms/v/s!Avet-jVvMtjmhBD80rGvPzYmWNXu?e=uZO71Q
Code in views
{% for item in author.user_select_certifikat %}
{{ item.label }}
{% endfor %}On page shortcode: [mbv name="certifikater"]
Its displayed on the author page in wordpress.
January 14, 2022 at 6:40 PM #33226Long Nguyen
ModeratorHi,
Can you please share your callback function
get_certifikat
?January 14, 2022 at 7:19 PM #33231vacdk
ParticipantWell, i don't thing the callback is the issue, as its doing the same with manual value and label.
But here is the callback
function get_certifikat( ) { $data=array(); $certificats = get_terms('certifikat', array('hide_empty' => 0, 'parent' =>0)); foreach($certificats as $certificat) { $data[$certificat->slug]=$certificat->name; } return $data; }
January 15, 2022 at 3:49 PM #33248Long Nguyen
ModeratorHi,
Thanks for providing the full info.
I've tried to reproduce the issue on my site but do not see that issue. Can you please use the shortcode without using Oxygen?
January 15, 2022 at 7:37 PM #33254vacdk
ParticipantHow can I do it without oxygen, I need a template to address the WordPress author page ??
/author/name
January 16, 2022 at 5:04 PM #33262Long Nguyen
ModeratorHi,
I'm able to reproduce the issue on the author page. The option
Post Author
in the MB Views insert fields tab needs the user to have at least one post to become an author. You can try to use the optionCurrent User
instead of that option.I've escalated this issue to the development team to fix the error message.
January 17, 2022 at 6:00 PM #33283vacdk
ParticipantOkay, thank you,
Wierd that content only can be displayed if they have posted a post, cause I add them as an author but they only become one after first post ?
But then I have another issue. I have created some CPT, but if they post in these, the author count is not working.
So MetaBox own CPT does not count as posts.
January 17, 2022 at 11:03 PM #33289Long Nguyen
ModeratorHi,
They have to create a post or be assigned to be an author to show the View content. Regarding the author of a CPT is not counted, I also experienced that issue. Thanks for your feedback, I will inform the development team to fix all issues.
-
AuthorPosts
- You must be logged in to reply to this topic.