Populate select list with meta values from all posts of a Custom Post Type

Here is the solution I came up with, that works properly. <form method=”get” action=”” onchange=”submit();”> <div class=”input-group”> <?php global $wpdb; $meta_key = ‘item_oem’; $data = $wpdb->get_results($wpdb->prepare( “SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s”, $meta_key) , ARRAY_N ); ?> <select class=”custom-select” id=”oems” aria-label=”oems” name=”item_oem” > <option selected>Search By OEM</option> <?php foreach( $data as $value … Read more

I’m having trouble with Related Product “tax_query” ‘terms’ value

How is ‘products_article_list’ meta returned from in $article_list? <?php $article_list = get_post_meta( get_the_ID(), products_article_list’, true);?> Is it a list of ids eg. ‘0601,0603’ or is it an array? tax_query terms argument requires an array. See https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters So if it’s stored as a list of ids all you need to do is explode the list and … Read more

get_posts query is taking about 40 seconds to execute

So, I actually fixed the issue by reversing the order of the OR conditions. If anyone knows why this fixed it, I’d love to know. $next_event = get_posts( array( ‘post_type’ => ‘event’, ‘post_status’ => ‘publish’, ‘numberposts’ => 1, ‘fields’ => ‘ids’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_post_date_year’, ‘value’ => $year, ‘compare’ … Read more

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