Forum Replies Created
-
AuthorPosts
-
September 2, 2020 at 5:28 PM in reply to: ✅How to assign a value to a taxonomy without showing it in the form in front-end? #21596
EddyPiV
ParticipantWhat I didn't mention is that the same (location) taxonomy is assigned to the page. I have a page for each location, with the [mb_frontend_form] command. My thought was that this [mb_frontend_form] can be the same on each page, and that the location can be derived from the taxonomy of the page.
Is there not a way to obtain the taxonomy value of the page and assign that to the taxonomy of the cpt?
That way, just one meta box would work for all locations.Back to your showcase with Work Place: still the location is not set. It remains empty.
Any advice?EddyPiV
ParticipantI just get an empty screen.
This is the view: https://share.getcloudapp.com/Apukg9Y9
This is the location: https://share.getcloudapp.com/DOuxKBqA
This is the page: https://share.getcloudapp.com/z8uZbrr5
These are the posts: https://share.getcloudapp.com/z8uZbrZQ
This is the result: https://share.getcloudapp.com/nOukLv58Why am I not seeing the 2 posts that are there that meet the criteria in the location?
September 1, 2020 at 9:27 PM in reply to: ✅How to assign a value to a taxonomy without showing it in the form in front-end? #21586EddyPiV
ParticipantHi Long,
Back to my original question:
"I have a form for a CPT, and I have a custom taxonomy (=location) assigned to that CPT, but the taxonomy is not part of the form. That is because each location has its own page showing the form in the front-end, and I do not want to bother the visitor selecting the location.How to assign the value for that location to the taxonomy-field when the user submits a new custom post, so that at another webpage (with an archive view) all custom posts for that location can be shown?"
your approach forces me to have a metabox for each location, while I was working towards 1 metabox for the cpt, and the taxonomy location assigned to it, but not being part of the metabox. Isn't there a way to achieve it with 1 metabox for the cpt?
In your showcase, the term for the location is shown to the visitor, while I want it to be hidden.
So wouldn't a hidden field with the value for the location in each metabox be better?Anyway, when I follow each step of your example, I see the following happening:
- in the admin area I see both Amsterdam and Rotterdam as fields assigned to each post of cpt Work Place, see https://share.getcloudapp.com/WnuJm6kr.
Probably because I have set both metaboxes to cpt Work Place, but I assume it needs to be set there, right?
- but the location remains empty (https://share.getcloudapp.com/p9uGeZmZ), although I have copied your php code in the snippet (https://share.getcloudapp.com/2Nuybp9E) and included the snippet shortcode in the page (https://share.getcloudapp.com/2Nuybpog).
Hence it seems not to be working.EddyPiV
ParticipantHi Long,
I understand that the different values of the taxonomy each have their own slug.
But what - in your example - if the block category is assigned to post, pages and cpt x, and I only want to see the items with category block for the cpt x?
EddyPiV
ParticipantHi Long,
The point is that the taxonomy is assigned to various posttypes: posts, media, pages, cpt's.
With your approach, I get them all, but I only want the posts.How to do that?
August 30, 2020 at 7:19 PM in reply to: ✅How to assign a value to a taxonomy without showing it in the form in front-end? #21540EddyPiV
ParticipantIt's obvious I am not a code writer...
I'm a bit puzzled: to set a value to the taxonomy should I use the rwmb_frontend_after_save_post or rwmb_frontend_after_process?
I think I understand your code
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
if ( 'xxx' === $config['id'] ) {
wp_set_object_terms( $post_id, get_queried_object_id(), 'location' );
}
}, 10, 2 );What I don't understand yet is:
- how to give a value ("Amsterdam") to the location
- how to give a value specific to the current page to the location, as I will have a page per location.
Does it take it from the current location of the page? (location taxonomy is also attached to pages).I have to set this php code in the functions.php file, right?
August 29, 2020 at 7:35 PM in reply to: ✅How to assign a value to a taxonomy without showing it in the form in front-end? #21525EddyPiV
ParticipantFor my understanding,
- $post->post_id must be the current post id,
- get_queried_object_id() is the id of the custom taxonomy to be set
- $taxonomy_slug is the value to be given to the taxonomy.
Right?How do I point here to the current post id?
For the rest, it should look like
add_action( 'rwmb_frontend_after_save_post', function( $post ) {
wp_set_object_terms( $post->post_id, 123, "Amsterdam" );
} );
where 123 is the id of the location taxonomy.
Is that correct?Where do I specify that action hook? Close to or with the [mb_frontend_form id="xxx"] command?
EddyPiV
ParticipantI understand what you are saying on selecting the taxonomy archive, makes sense to me.
So I changed it accordingly. https://share.getcloudapp.com/geuzOjGLBut the result is the same: I only see 1 item listed: my current page, not any posts!
Because I will have a seperate archive view for each value of the taxonomy, I think I need for each value a separate page with the shortcode of the view.
Is that correct?So that's what I did, but it's not working.
EddyPiV
ParticipantThanks Long, it disappeared.
EddyPiV
ParticipantHi Long,
This is really helpful! I managed to get the view exactly as I wanted.
Except for 1 thing: under the sidebar there is always the number "1" shown, and I have no idea why that is.
https://share.getcloudapp.com/RBuqBxy6Any clou?
EddyPiV
ParticipantHi Long, the developer of the theme has provided me with a solution.
Thanks for your help.EddyPiV
ParticipantHi Long, thanks so much for your help. Much appreciated.
I noticed that within the archive view, for render "Only the post content area" it does not show the featured image. Actually, none of my settings are applied. It seems completely ignored.
For render "The layout between header and footer" the featured image is shown, but after the theme's header image, not replacing it.
I am not a real developer, so I prefer to stick as close as possible the the theme, hence using render "Only the post content area". But how to have my view settings applied, as well as the featured image replacing the theme's header image?
I hope you can help me further.
EddyPiV
ParticipantJust managed to send it to you through another browser.
EddyPiV
ParticipantHi,
Yes I am using a Pro theme. Trying to send it to you, but the recaptcha on the contact page is hard to pass, as the header with the instruction whhat to do is not shown properly. see attached. https://share.getcloudapp.com/2Nu5Ppv2
So if you can help me there first...
EddyPiV
ParticipantHi,
Interesting... I have installed the AIO plugin, which was latest released om June 2nd.
I see that the Toolbar plugin you are referring to has release date June 3rd.How do I install that version?
-
AuthorPosts