Get Child Category only

So if I understand correctly, the problem here is that get_the_terms(..) returns both the parent and child category. As you said in the comment, there will only ever be 1 parent and 1 child in it, we can use that information to get the correct term. Basically we need to filter the results, we know … Read more

Query_vars support in Rest API

correct me, if i’m wrong, but query vars are not processed in REST requests. but there is other ways to make this work. not really sure, if this will help with your problem but hopefully it is at least a push in the right direction function so380236_rest_cpt_query($args, $request) { $query_params = $request->get_query_params(); if (!array_key_exists(‘city’, $query_params)) … Read more

Combine 2 WP_queries into one (OR relation)

meta_query can only be used for meta queries, you can’t use it for non-meta parameters. Even if you could, it would not give a performance benefit. What you want can’t be done, and your second example is searching for posts that have a post meta named post_parent. The canonical answer, is to use 2 query … Read more

Shortcode Not Working in Slider When Added To Post Title

do_shortcode() returns the content you pass it with the shortcodes, if any, filtered out (ie, processed). So the code you’ve posted in your question won’t work the way you want it to: do_shortcode( get_the_title() ); printf( ‘<h2><a href=”%s” title=”%s”>%s</a></h2>’, get_permalink(), the_title_attribute( ‘echo=0′ ), get_the_title() ); Instead you’ll need to do something more like this: $title … Read more

Does WordPress have something like Drupal’s DB API?

Yes, there’s the wpdb class. Some examples can be found for e.g. here. Then there’s the global $wpdb object that contains results and other parts, set based on the current routing. You can also utilize the WP_Query class which is more common. There’s a default global $wp_query object and the $wp_the_query(?) intermediary object, that holds … Read more

Get user first name from custom endpoint

If you look at the documentation, first_name is not in the list of accepted values for the fields parameter, and if you enabled debugging, you’d see adding first_name to that parameter would actually cause a database error — Unknown column ‘wp_users.first_name’ in ‘field list’. And the same goes to the “firstname” and any other non-standard … Read more

get term id from term name

Try to use get_term_by(), where first argument is a field, in your case – name. Second is your value. I used esc_attr() to make it secure. Third one is taxonomy, as example I put here category. if ($_SERVER[“REQUEST_METHOD”] == “GET” && $_GET[‘fname2’] && $_GET[‘fname’]) { $nameb = get_term_by(‘name’, esc_attr($_GET[‘fname2’]), ‘category’); $namea = get_term_by(‘name’, esc_attr($_GET[‘fname’]), ‘category’); … Read more