Using get_posts to get posts based on a checkbox value with Advanced Custom Fields

OK, I found the answer here: WP Query post meta value Turns out you have to use the serialize php function due to how wordpress stores arrays in the database. function get_city_jobs() { $city = ($_GET[‘city’]); $city = trim(ucfirst($city)); $args = array( ‘post_type’ => ‘careers_post_type’, ‘numberposts’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘city’, … Read more

get_posts custom field

If you want to use post meta for setting which posts are displayd on the front page, then I would recommend saving the setting with a separate meta_key. So instead of pushing it to the your_fields save it with its own key. This means modifying your metabox content to have something like this, <input type=”checkbox” … Read more

Is it possible to use array_walk() to append terms to an array of posts?

I guess you have a problem with variable scopes in here. array_walk($terms, function(&$term, $term_index) { // die(print_r($term)); if (isset($term->slug)) { array_push($post->terms, $term->slug); } }); In this part of your code, you use anonymous function and inside of it you use $post variable. But it is a different variable than the one from few lines back … Read more

get_posts() from parent category only using a shortcode

If you don’t want to include posts in child categories, use the category__in parameter: $args = array( ‘category__in’ => [ get_cat_ID( $category_name ) ], // use category__in //’category_name’ => $category_name, // and not this. ‘post_type’ => ‘menu’, ‘numberposts’ => -1, ‘post_status’ => ‘publish’ ); And although the above would give you what you wanted, the … Read more

Check if searched number is within the post meta value

Assuming your “property-guests” taxonomies have names like “1”, “2”, “3”, etc.: <?php // Get the number of guests the visitor searched for $requiredGuests = $_POST[‘guests’]; // Get all terms in the “property-guests” taxonomy // (By default, this will only include terms that are assigned to something) $allGuestNumbers = get_terms(array(‘taxonomy’ => ‘property-guests’)); // Create a variable … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)