Skip Navigation

[Resolved] Need the equivalent PHP code for this shortcode

This thread is resolved. Here is a description of the problem and solution.

Problem:
PHP function to get term meta fields

Solution:
See one example below:

$vendorstatus = get_term_meta( $vendorid, 'wpcf-account-status', true );
This support ticket is created 8 years, 2 months ago. 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.

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

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 7 replies, has 3 voices.

Last updated by Adriano 8 years, 2 months ago.

Assisted by: Adriano.

Author
Posts
#366134

I am trying to: Create the PHP equivalent to this shortcode generated by Types 1.9

[wpv-taxonomy-field name="family"]

It's for a taxonomy field I created using Types 1.9. I'd like to use PHP code instead of the shortcode.

Please provide the equivalent PHP statement.

Thanks

#366364

Thank you for contacting Toolset support, I'd be delighted to assist!

This shortcode is actually registered in Views, I cannot share the code here as it's a paid plugin..

Another way is to use get_term_meta, such as get_term_meta( $term_id, 'feature-group', true );
This can help: hidden link

You can easily find how our shortcodes are registered by performing a project wide search in tools such as Atom, for example searching the Views plugin.

Note that this shortcode is inside the filename "wpv-deprecated.php" so I'm not sure if it'll be going away soon.

I hope this helps!

#366383

Hi

Your answer doesn't make any sense to me. First of all, there is nothing proprietary about querying data from WordPress. So I don't know why you believe there is something proprietary about how you query WordPress in your shortcodes and cannot reveal it here.

Second, the actual shortcode code is in the "wpv-shortcodes.php", it's only referenced in "wpv-deprecated.php".

Third, your code is using the same "get_term_meta" you told me to use as per that article, which I have already tried.

My reason for asking for support is that Toolset sometimes adds things to field names, for example it does that when you create a custom field, it appends wpv or something similar to the field name.

When I was not able to access this data with "get_term_meta" I suspected that something similar was going on. Maybe when I created that field it somehow put it into a group or appended something to the name.

Please pass my question onto Caridad if she is still available. I still need help with this. Or Juan if he is available.

Thanks

#366389

Hello there!

The shortcode is only referenced in the code of the Views plugin, which is a paid product and code cannot be posted publicly. My Tier 2 recommended that I share the get_post_meta option as the best solution.

As Caridad is no longer with us, I have sent this over to Juan for you custom coding project. Thank you for your patience!

#366390

Thanks for sending it to Juan. I took a closer look at the shortcode code itself and it does look like something is getting appended to the field name.

It looks like it is appending "wpv-taxonomy-field-meta-" to the field name, but it will be better if Juan can provide an example of how to query a Types-created taxonomy field name using PHP.

#367241

Hello,

I’m not Juan but I'll try to help you. I'm Adriano, Toolset support lead and I have been escalated to this thread. I’ll give my best to help you to achieve your needs through Toolset components.

Where you want to insert that PHP code? Archive page?

#367851

Hi Adriano

Thanks, but I did work it out by myself. I found that Types adds a prefix to each field name you create so a field named "account-status" is actually written to the database as "wpcf-account-status".

Once I realized this I was able to use code like this to get the values I needed.

$vendorstatus = get_term_meta( $vendorid, 'wpcf-account-status', true );

#367986

Great, thanks for sharing!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.