Skip Navigation

[Gelöst] Accessing posts by slug instead of post id

This support ticket is created vor 5 Jahre, 1 Monat. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Dieses Thema enthält 4 Antworten, hat 3 Stimmen.

Zuletzt aktualisiert von alekseiS-2 vor 5 Jahre, 1 Monat.

Assistiert von: Christian Cox.

Author
Artikel
#1236591

I want to be able identify specific posts by using the post SLUG rather than the post ID.

e.g. I'd like to be able to use

[wpv-post-title item='slug-of-post']

instead of

[wpv-post-title item='845']

but the Item Attribute does not allow for this.

In the worst-case scenario (Plan C), I can adjust my design to use Post IDs, but it's going to be MUCH easier to develop my application if I can use slugs. (I'll be creating a lot of posts with fields that refer to other posts and fields: when I get to populate those fields, I know from the context exactly what the slug is that I need to use. If I have to use IDs I'll have to ensure the post is created first before I can reference it, and go and find out what the ID is.)

Plan A is to double-check that I can't do this with built-in toolset shortcodes: that's the essence of what I'm asking here.

Plan B is to write my own shortcode to convert from slugs to IDs and then use those IDs in Toolset shortcodes. So - a subsidiary question I'm asking here is to ensure I'd not be trying to do something impossible!

Thanks!

#1236611

Actually, I found it was very easy to write the shortcode to get the ID from the slug and post-type (Plan B).

So, unless I missed some built-in method using Toolset, I'm fine now.

#1236672

Yes, I think a custom shortcode is your best bet here. There's nothing built-in to Toolset that will allow you to use slugs instead of IDs in the item attribute, as defined here: https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/

#1236748

My issue is resolved now. Thank you!

#1815317

Hello alexG-4. Can you tell me how did you do that?

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.