Sort on two variables

So long as every listing has a feature_posi field (even if it’s empty), you can let WordPress/MySQL handle the ordering for you: $args = array( ‘post_type’ => ‘listing’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title meta_value_num’, ‘order’ => ‘ASC’, ‘meta_key’ => ‘feature_posi’, ‘tax_query’ => array( array( ‘taxonomy’ => $taxonomyName, ‘field’ => $term_slug, ‘terms’ => get_queried_object()->term_id, ) … Read more

Adding an IF Function to Current Custom Category If has Child

If you asking about $terms has child then only go for it. With this you can try below code as solution: <?php ( $terms = get_terms([ ‘taxonomy’ => get_queried_object()->taxonomy, ‘parent’ => get_queried_object_id(), ‘hide_empty’ => false ])); // get_terms will return false if taxonomy does not exist or term wasn’t found. // term has children if($terms){ … Read more

Is there a way to have chunks of a page’s content expire?

If you don’t mind wrapping your content in Shortcode then you can easily have them hidden after a specific time. Granted you don’t cache the page for longer than needed. Wrap your content in [content_expires] shortcodes. Time should be based on your server’s timezone. [content_expires]NEVER Expires[/content_expires] [content_expires date=”2016-10-25 00:00:00″]PAST[/content_expires] [content_expires date=”2116-10-26 04:20:00″]FUTURE[/content_expires] Then add the … Read more

Query Posts from Custom Field Value Taxonomy Set by Admin

You cant run query based on taxonomy only. You also need to provide the taxonomy term the custom post type post associated with. Change your $args like below – $args = array( ‘post_type’=> ‘products’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘cosmetics’, // your taxonomy ‘field’ => ‘term_id’, ‘terms’ => get_term_by(‘name’, $foo, ‘cosmetics’)->term_id, // your taxonomy … Read more

Store stripe info as user_meta

Sounds like the $amount variable is empty so it’s not saving. Echo it out to see what’s happening. Make sure the $payment_user_id is an actual WordPress user_id. Wrap your update_user_meta within the if statement. // If charge is successful, store in user meta if (isset($event) && $event->type == “charge.succeeded”) { $amount = $event->data->object->amount / 100; … Read more

get_category display only 1

Added an argument for the $categories Input the ID of the parent to display all the subcategories. function ba_SearchFilter($query) { if (!$query->is_search) { return $query; } if (isset($_POST[‘cat’])){ $query->set(‘category__and’, $_POST[‘cat’]); } if (isset($_POST[‘tags’])){ $query->set(‘tag__and’, $_POST[‘tags’]); } return $query; } //hook filters to search add_filter(‘pre_get_posts’,’ba_SearchFilter’); function ba_search_with_filters(){ $out=”<form role=”search” method=”get” id=”searchform” action=””. home_url( “https://wordpress.stackexchange.com/” ).'”> <div><label … Read more

Edit errors on login and lost password screen in wordpress

you can change the message in login screen by using login_errors filter hook, just paste this code in the themes functions.php file : add_filter(‘login_errors’,’login_error_message’); function login_error_message($error){ //check if that’s the error you are looking for $pos = strpos($error, ‘incorrect’); if (is_int($pos)) { //its the right error so you can overwrite it $error = “Wrong information”; … Read more