GD Listings by ID

This topic contains 21 replies, has 6 voices, and was last updated by  Alex Howes 5 years, 11 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #430504

    Alex Howes
    Expired Member
    Post count: 175

    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 🙂
    Alex

    #430510

    Alex Rollin
    Moderator
    Post count: 27815

    No, that is not a documented param.

    I will flag your topic for the developers and we can see what they say.

    #430514

    Alex Howes
    Expired Member
    Post count: 175

    Thanks, that’d be helpful 🙂

    #430544

    drashida
    Expired Member
    Post count: 129

    Hi,
    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.

    #430546

    Alex Howes
    Expired Member
    Post count: 175

    Cool, 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?

    #430608

    Kiran
    Moderator
    Post count: 7069

    Hello,

    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

    #430645

    Alex Howes
    Expired Member
    Post count: 175

    Hello

    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.

    #430648

    Kiran
    Moderator
    Post count: 7069

    Add 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

    #430649

    Alex Howes
    Expired Member
    Post count: 175

    Hi 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 🙂
    Alex

    #430651

    Dirk
    Full Member
    Post count: 390

    @alex,

    I 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,
    Dirk

    #430652

    Dirk
    Full Member
    Post count: 390

    the WP function for adding tags to a post is:
    https://codex.wordpress.org/Function_Reference/wp_set_post_tags

    #430656

    Kiran
    Moderator
    Post count: 7069

    Try 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.

    #430657

    Alex Howes
    Expired Member
    Post count: 175

    Thanks Dirk
    I’ve now added the following code

    
    
    wp_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.

    #430682

    Paolo
    Site Admin
    Post count: 31206

    wp_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

    #430684

    Alex Howes
    Expired Member
    Post count: 175

    Cool, that’s working, thanks a lot for your help with this 🙂

Viewing 15 posts - 1 through 15 (of 22 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket