Robert Strobel
Forum Replies Created
-
AuthorPosts
-
Thanks a lot Kiran. Much appreciated.
Ok i’m looking for a short term solution not v2, give me a heads up… how can it be done?
We have different titles and different meta tags plus different images per category, they do not all follow a format like the defaults…
Because first of all we need a title, desc and also OG tags and an image meta too.. i dont see those options from GD
This reply has been marked as private.This reply has been marked as private.Thanks a bunch Stiofan!!
Here’s the code I used for any users who may have same query I had:
global $wpdb, $plugin_prefix; $existing = $wpdb->get_results($wpdb->prepare( "SELECT * FROM {$wpdb->posts} p JOIN " . ($plugin_prefix . 'gd_customdir_detail') . " gd ON gd.post_id=p.ID WHERE gd.geodir_test_val=%d LIMIT 1", array(1000) ));//works
We’re set now. Thanks for the help again.
Ok so I installed that and looked at the documentation. Straight forward but I see no examples or references on filtering.
I tried normal wordpress filtering but it didn’t work
$curl = curl_init(); $field_string = http_build_query(array( 'filter[meta_query]' => array( array ( 'key' => 'geodir_test_val', 'value' => "1000", ) ), )); curl_setopt_array($curl, array ( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => site_url('wp-json/geodir/v1/customdir?' . $field_string) ) ); $existing = json_decode(curl_exec($curl));
However the above code brings back all listings and not filtered by field/meta.
I understand replies take a little bit of time. Are you able to guide me here as I don’t see anything further on the REST API docs.. thanks!
What would the rest api URL be for filtering the listing by custom field?
This is for simply getting the post data nbased on a meta key. That is not even possible?
I know update/insert what stiofan mentioned.. that’s already covered. But i’m talking about just getting the post data ie post id.
Thanks Alex.
I tried this simple query to retrieve listings by custom field value. Since I first need the $post_id to use geodir_get_post_info() or _get_post_meta() —
$existing = (new WP_Query(array( "meta_query" => array( array( "key" => "geodir_test_val", "value" => "100", // 'compare' => 'IN' ) ) )))->posts;
However this returns an empty array, however there is a listing with the custom field value “100” as I created it manually to test with.
Much thanks for info so far. It has been helpful and insightful.
Thank you very much.
Lastly, for custom fields, is there some prefix?
If i made a custom field called “Test Val” and it’s html variable is test_val then what would the meta key be? Would it be geodir_test_val or would it be test_val?
My use case is:
We have a variable called$testvalue = "testval";
We want to use this $testvalue to update geo directory listings that have a custom field “Test Val” as the same value a this variable $testvalue
Also, we want to be updating other custom fields within the geodir_save_listing() callThe goal is to insert a record if it does not already exist with the custom field as $testvalue and if it exists, then update instead
Thank you Stiofan for that link! Very helpful
To confirm, geodir_save_listing() can be used for both insert and update right? Would you be able to give a simple example of an update based on custom field?Which function would I use to get a listings data? Maybe something like geodir_get_listing?
Thanks again!
Thanks
FYI i found the following code that helped me with taxonomy usage for caegories..
pasting for anyone else who may read with the same need..
function geodir_taxonomy_breadcrumb() { $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $parent = $term->parent; while ($parent): $parents[] = $parent; $new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' )); $parent = $new_parent->parent; endwhile; if(!empty($parents)): $parents = array_reverse($parents); foreach ($parents as $parent): $item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' )); $url = get_term_link( $item, get_query_var( 'taxonomy' ) ); echo '<li> > <a href="'.$url.'">'.$item->name.'</a></li>'; endforeach; endif; echo '<li> > '.$term->name.'</li>'; }
-
AuthorPosts