Custom Custom Fields (schema)

This topic contains 8 replies, has 4 voices, and was last updated by  Paolo 8 years, 1 month ago.

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

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #263702

    wasanajones
    Buyer
    Post count: 180

    3 questions – I appreciate the time needed to read and decipher these but I think there would be feature value.

    Q1
    I’m hoping to create a custom field where the user enters text and we can wrap text around that entry. for example to make a shortcode. [shortcode trigger=”What is Entered in Field”] – but I have a feeling shortcodes created like this won’t get triggered.

    Q2
    I appreciate the tip for adding a Custom Field to upload logos found https://wpgeodirectory.com/docs/custom-field-examples/ but wondering what it might take to add the ‘logo’ schema.org: <img itemprop=”logo” src=” described https://schema.org/logo

    there would also be something related to Brand associated with the logo, but I don’t understand enough about schema.org to even ask the question for that one.

    Q3
    Also related to a custom field that adds schema.org would be the ability to do SameAs schema https://schema.org/sameAs to point NAP to another website.

    I think proper use of the itemprop schema requires them to be associated within itemscope – so not sure how logo, brand, sameAs would work with custom fields – maybe reusing the itemscope organization schema entered when creating the listing.

    div itemscope itemtype=”http://schema.org/Organization”>
    <b href=”http://www.example.com/”>Home

    /div

    Not sure if Custom Fields are the appropriate place for these or editing Page Templates might be more suitable – but not sure how complicated that would get either.

    #263704

    wasanajones
    Buyer
    Post count: 180

    the sample didn’t fare too well… and now can’t edit, try again

    
    
    <div itemscope itemtype="http://schema.org/Organization">
      <a itemprop="url" href="http://www.example.com/">Home</a>
      <img itemprop="logo" src="http://www.example.com/logo.png" />
    </div>
    #263821

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I’ve flagged this for Stiofan. He’ll let you know his thoughts asap.

    Thanks

    #263833

    wasanajones
    Buyer
    Post count: 180

    thanks, look forward to hearing more about this

    #264639

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    #1
    This will enable shortcodes in all text fields

    This will enable shortcodes in any text infput with a htmlv var name of ‘textx’

    If you wanted to do the same for a textarea you would simply change the line

    add_filter('geodir_custom_field_output_text','my_enable_shortcodes_in_cf',15,3);

    to:

    add_filter('geodir_custom_field_output_textarea','my_enable_shortcodes_in_cf',15,3);

    #2 We add schemas the new way so they don’t have to be next to the field but instead are added as JSON in the head, below is an example of adding a logo

    #3 We already add sameAs for the website link and the facebook/twitter links, the way to add it is almost the same as the above example except the sameAs is an array so it’s slightly different

    Thanks,

    Stiofan

    #264645

    wasanajones
    Buyer
    Post count: 180

    thank you for the detailed reply – I’ll dig into it see what fancy stuff I can make

    #264646

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Just let us know if you run into any problems 🙂

    Stiofan

    #275286

    marktowers
    Buyer
    Post count: 171

    Hi Stiofan,

    Just found this thread and was curious about the shortcode question. Is the intention to be able to use a shortcode to display the values in a custom field, or to use a shortcode to add some custom text based on what has been input in to a custom field?

    To explain the reason for my query, I would like to be able to create a shortcode that could be used to display all values in a given custom field. So, for example, if I had a custom file upload field of logos I was hoping to then display all the logos on a page. So, would I be able to adapt the “my_enable_shortcodes_in_cf” function mentioned above for this purpose?

    Thanks,
    Mark

    #275468

    Paolo
    Site Admin
    Post count: 31206

    hi,

    this is to enable a text field (or textarea) to parse a shortcode.

    If now you enter a shortcode example: [gallery xyz] in a custom field it will display it in the front end as text: [gallery xyz] instead of showing what the shortcode is supposed to output.

    What you need to do is not achievable through this method. If you need a shortcode that takes the logo custom field of all listings, to show it as a list on a custom page, that would require everything to be developed from scratch.

    Thanks

Viewing 9 posts - 1 through 9 (of 9 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