Open manuelcanonad opened 3 years ago
Hi, I think the correct code should be this. Please note: tp_meta_pub_custom_label is a placeholder for the ID of the custom field, which is displayed in the meta data screen for publications.
$args = array(
'meta_key_search' => array( 'tp_meta_pub_custom_label' => '{Health}' )
);
$output = TP_Publications::get_publications( $args );
Hi Michael,
Thank you so much for your help!
I would like to know if I can to put into a shortcode any value of a metadata like the ID or the metadata name.
Thanks!
Hi Michael!
Another question is the next: I want to put into your code a variable like this:
$args = array( 'meta_key_search' => array( 'tp_meta_pub_areas_de_investigacion' => $metadata ) );
But It doesn´t work. How can I get it?
THANKS in advance!
It should work if $metadata
contains the correct form for the value, you want to find. That's something I forgot in the first post:
// If your custom field is a CHECKBOX: The value must enclosed by curly brackets
$metadata = '{Demo Value}';
// For all others this isn't necessary
$metadata = 'Demo Value';
// Your search
$args = array( 'meta_key_search' => array( 'tp_meta_pub_custom_label' => $metadata ) );
Please note in addition, that this meta key search is currently only a "is equal search" over the field "meta_value" in the table "teachpress_pub_meta".
Hi Michael, could you offer an optimal way to include meta_key_search in your shortcodes as well? or do you have any plan to implement it?
Actually there is no way currently - but I have added two separate arrays in the main shortcodes atts for keys and values with commas between array items then exploding them into the array of your meta_key_search. (as there can be more than one meta key) meta_keys('key1', 'key2') meta_val('val1', 'val2')
meta_key_search('key1'=>'val1', 'key2'=>'val2')
These customizations are always lost while update. Therefore it would be great if it is included by default.
Hi!
I'm trying to use the meta_key_search parameter to show the meta value of a publication, but I do not know how it is used. my code is the following:
$args = meta_key_search => array( 'tp_meta_pub_custom_label' => '{Health}' )
Thanks!!