GD Listings by ID
This topic contains 21 replies, has 6 voices, and was last updated by Alex Howes 7 years, 5 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
May 14, 2018 at 3:53 pm #430504
Hello,
Is it possible to show listings by specifying the listing ID? I had a look through here https://wpgeodirectory.com/docs/core-shortcodes/#listings but it doesn’t seem to be a parameter.
Thanks 🙂
AlexMay 14, 2018 at 4:12 pm #430510No, that is not a documented param.
I will flag your topic for the developers and we can see what they say.
May 14, 2018 at 4:17 pm #430514Thanks, that’d be helpful 🙂
May 14, 2018 at 6:33 pm #430544Hi,
I requested a single post shortcode for events about a year and a half ago. Found your post as I was checking back. I was offered a workaround. (#307867) To tag the post with a unique tag:[gd_listings post_type=gd_event layout=1 tags=’YOUR-UNIQUE-TAG’ category=157]
Hope this helps.
Geodirectory, I think a listing ID would be a helpful parameter.
Thanks.
May 14, 2018 at 6:44 pm #430546Cool, thanks drashida, that seems like a good way to make it work 🙂
Do you know if there’s a way to add a unique tag programmatically?
May 15, 2018 at 6:43 am #430608Hello,
It is not possible without core customization. But you can manage as @ayecode_alex said.
Ex:
[gd_listings post_type=gd_event layout=2 listing_width=100 character_count=140 post_number=1 with_pagination=0 event_type=”upcoming” tags=”museum”]add any unique tag to the event that you want to display.
Kiran
May 15, 2018 at 11:10 am #430645Hello
Thanks, I’ll do that. Is there a way to add a unique tag programmatically? I tried geodir_save_post_meta($value,’post_tags’,$value) but it doesn’t work.
May 15, 2018 at 11:23 am #430648Add tag just as normal.
Go to admin > Events > Edit event that you want to display > add tag to event (in Tags metabox at right sidebar) > Save
May 15, 2018 at 11:28 am #430649Hi Kiran,
I need to do it programmatically as part of a snippet. I’ve got a job CPT, and I’ve written some code that records the job id if a worker applies to that job. As the final part of this I want to list the jobs that a worker has applied to in their profile. My plan was just to do an “echo do_shortcode[gd_listings]” and specify the listing ID, but since this isn’t possible I’ll have to add the tag programmatically and specify it that way.
Is there a way to add a tag programmatically?
Thanks 🙂
AlexMay 15, 2018 at 11:46 am #430651I like to suggest here:
Export your CPTs, process in an editor (you can easily code what you like for example a macro) and then import the changes. Is much easier than coding on a live database.Best,
DirkMay 15, 2018 at 11:49 am #430652the WP function for adding tags to a post is:
https://codex.wordpress.org/Function_Reference/wp_set_post_tagsMay 15, 2018 at 12:28 pm #430656Try this:
$tag = 'museum'; geodir_save_post_meta( $post_id, 'post_tags', array( $tag ) ); wp_set_object_terms( $post_id, array( $tag ), get_post_type( $post_id ) . '_tags' );Replace “museum” with your own tag.
May 15, 2018 at 12:28 pm #430657Thanks Dirk
I’ve now added the following codewp_set_post_tags($value,"$value",false); echo do_shortcode('[gd_listings post_type=gd_cv layout=1, tags="$value"]');where $value is the id of the listing I want to show. It’s showing all listings of the type gd_cv so I think the GD tag filter isn’t working.
May 15, 2018 at 4:05 pm #430682wp_set_post_tags will only add a tag in wp default db tables. We filter based on our table using our own API. Please try what Kiran suggested here: https://wpgeodirectory.com/support/topic/gd-listings-by-id/#post-430656
Let us know if that works
May 15, 2018 at 4:11 pm #430684Cool, that’s working, thanks a lot for your help with this 🙂
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket