Forum Replies Created
-
AuthorPosts
-
EddyPiV
ParticipantThanks Long.
It works. I have managed to further adjust it to my liking.
Except for the pagination, that doesn't work, no paging is shown. Any light on that?EddyPiV
ParticipantThat I understand, and I did that before. But I got stuck on the coding, as I didn't manage to get the post link and the featured image of the post. That's what I meant when I said that the coding is more difficult for me in this approach.
So perhaps you can help me with the correct code for getting the post link and the post featured image?
EddyPiV
ParticipantHi Long,
There is now 1 view of a Custom Type. As the coding for custom type is harder for me to understand/specify, I prefer to use an Archive Type.
Your comment on various views of Archive Type causing problems confuses me. It's a bit as I mentioned earlier: I don't understand the relation between the Archive Location settings and the url it relates to.
E.g. I need different archive-views for ../location/amsterdam/?post_type=post and ../location/amsterdam/?post_type=event, and for ../location/rotterdam/?post_type=post
How to define that in the Archive Location settings?My problem was that my View seemed to be ignored, perhaps because my Archive Location settings were incorrect.
EddyPiV
ParticipantI have done that, but still the view seems ignored: all posts, pages and cpt’s for this value of the taxonomy are shown, and the initial text “This is the archive view” does not appear.
EddyPiV
ParticipantActually, I believe I don't understand how the location works in relation to the url of the acrchive page.
Just a simple location is okay, but once it gets more (AND / OR relations) I am lost.
Although in the case above, even with a single condition it already seems ignored...
So if you please could elaborate...EddyPiV
ParticipantHi,
I am confused, I still couldn't figure out how to get all posts for a specific value of a taxonomy.
It looks like my view is ignored at all.This is the view: https://share.getcloudapp.com/12uJlQwX
This is the location: https://share.getcloudapp.com/Z4ukNpQ8,
This is the value for the taxonomy: https://share.getcloudapp.com/RBuOAkKL
This is the result: https://share.getcloudapp.com/nOuk7JBw
It shows just all posts, pages and cpt's for this value of the taxonomy. Also, the initial text "This is the archive view" does not appear.Your help is much appreciated...
EddyPiV
ParticipantOkay, that clarifies that part.
Then I proceed with the Custom view, and I will include the shortcode.
I have adapted the view according to your advise, but it seems it finds no records: I get 5 items, each without title, excerpt etc, but all with the current date & time.
https://share.getcloudapp.com/YEuozDmvSeptember 3, 2020 at 5:30 PM in reply to: ✅How to assign a value to a taxonomy without showing it in the form in front-end? #21621EddyPiV
ParticipantHi Long,
Excellent, now it's all working!
Thanks so much for your help.
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? #21596EddyPiV
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?
-
AuthorPosts