Embedding Custom Fields Dynamically

This topic contains 20 replies, has 4 voices, and was last updated by  Guust 4 years, 9 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #532707

    Peter Johnson
    Full Member
    Post count: 14

    I’m interested in being able to create a sentence that is filled in with information from text-based custom fields. For example, I would like to be able to do something like this…
    “[post-title] is near [city] in the US state of [region].”

    Is there a shortcode I can use to pull text from other custom fields to dynamically do this? Or, is there a plugin you would recommend?

    #532708

    Guust
    Moderator
    Post count: 29970

    You can use this, but will need to add CSS to fine-tune it:

    [gd_post_meta key="post_title" show="value-strip"] is near [gd_locations what="city" show_current="1"] in the US State of [gd_locations what="region" show_current="1"]

    It can only be used in the Detail and Archive Item template.

    Thanks

    #532803

    Peter Johnson
    Full Member
    Post count: 14

    Thanks! In addition to city and region, I’d also like to add text from textarea content fields. (I’m currently working in the gd_place CPT) For example, I want to be able to do something like this…
    [gd_post_meta key=”post_title” show=”value-strip”] is a [type].
    (In this example, “type” is an example of a custom field.)

    Is there a shortcode that can accomplish this? Also, if there is any documentation that exists on this topic, feel free to point me to it so I don’t have to keep bugging you. Thanks for your help!

    #532819

    Kor
    Moderator
    Post count: 16516

    Hi Peter,

    Thanks for your reply. With GD post meta, you can call the custom field “type” directly using the shortcode below.

    [gd_post_meta key="type" show="label"]
    #532829

    Peter Johnson
    Full Member
    Post count: 14

    I inserted the following line into a textarea custom field to test the shortcode:
    This place is a [gd_post_meta key=”type” show=”value”].

    It was successful at inserting the type, but it puts the value on a new line rather than on the same line. The output looks like this:
    This place is a
    hotel
    (there is a line here)
    .

    How do I make it look like this:
    This place is a hotel.

    If you are able to answer this question, I should be good to go. Thanks again for all of your help!

    #532832

    Kor
    Moderator
    Post count: 16516

    Hi Peter Johnson,

    Thanks for your reply. We might need to apply some custom CSS code to fix this. Do you have a test page to show me what you’ve done?

    #532880

    Peter Johnson
    Full Member
    Post count: 14
    This reply has been marked as private.
    #532916

    Guust
    Moderator
    Post count: 29970

    Can you turn off all plugins and modifications so everything works again?
    None of your pages are working at all.
    Go back to basics and only activate plugins you need and then make sure they are not breaking things.

    #532943

    Peter Johnson
    Full Member
    Post count: 14
    This reply has been marked as private.
    #532950

    Guust
    Moderator
    Post count: 29970
    This reply has been marked as private.
    #533007

    Peter Johnson
    Full Member
    Post count: 14
    This reply has been marked as private.
    #533024

    Peter Johnson
    Full Member
    Post count: 14

    I fixed my site. My htaccess file was missing several lines. Everything works now. If you don’t mind taking a third look at my site to help with the original issue, I would be extremely grateful!

    Kor suggested creating custom CSS, which could work. I’m wondering if there is a way to just create something that could be added to the shortcode that strips the embedded custom field of all CSS relationships so it can take on the CSS of the content field containing the shortcode. Anyway, just a thought. I wouldn’t be surprised if this would be useful to other people as well.

    #533027

    Kor
    Moderator
    Post count: 16516

    Hi Peter,

    Thanks for your reply. I’m actually referring to this “Extra Class” option as shown in the attached screenshot. Inserting a custom CSS name should all you to apply custom CSS code to achieve what you needed there.

    #533031

    Alex Rollin
    Moderator
    Post count: 27815

    We have had several requests for this and we have a task to look into adding this, but for now it requires your own custom CSS.

    Thanks

    #533188

    Peter Johnson
    Full Member
    Post count: 14

    I’ve read all of the documentation I can find on the Geodirectory site about the CSS Class field. Below is one of the several versions of the shortcode that I tried. It doesn’t seem to be fully changing the CSS to match the surrounding text. It still puts the word on a separate line and it still puts a line below the inserted word. Are you able to see what is wrong with the shortcode below? Is the CSS class wrong if I want it to conform to the CSS of a details/listing page? Thanks for your help.

    CSS Class- Single gd place
    This place is a [gd_post_meta key=”type2″ show=”value” css_class=”single-gd_place”]

    Sources I used to try to figure this out…
    https://wpgeodirectory.com/docs-v2/faq/common-examples/#selectors
    https://wpgeodirectory.com/docs-v2/places/custom/#settings

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

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

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount