How to display related posts by same publish date?

Get the date of current post: $date = get_the_date(‘Y-m-d’); Get year, month and day from the $date variable. $exploded = explode(‘-‘, $date); $year = $exploded[0]; $month = $exploded[1]; $day = $exploded[2]; Lastly, query the posts that has the same publish date. $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘date_query’ => array( array( ‘year’ … Read more

Custom query for sidebar isn’t returning results

Based on our chat in the comments here’s what I came with. Please advise if it works. <?php function primary_category_query_shortcode( $post, $atts ) { //global $post; //Uncomment this global if it still doesn’t work. $atts = shortcode_atts( $defaults, $atts, ‘primary_category_query’ ); $my_meta = get_post_meta ( $post->ID, ‘_yoast_wpseo_primary_category’, true ); // WP_Query arguments $args = array … Read more

Custom query to filter posts that have current post as a taxonomy [closed]

I made it through! I’ll share how I did in case some other person lacking the php knowledge like me lands in the same spot. add_action(‘elementor_pro/posts/query/projects_designs_query’, function($query) { $post_id = get_the_ID(); $meta_query[] = [ ‘post_type’ => ‘designs’, ‘taxonomy’ => ‘projects’, ‘value’ => $post_id, ‘compare’ => ‘in’, ]; $query->set( ‘meta_query’, $meta_query ); } ); What this … Read more

Order By Post Type ThenBy Taxonomy

yes, offcourse it is possible, I had made two websites for selling car pieces myself and that is very possible. anything is possible. you can create your own search results with the file search.php here are two ways of getting products info: $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 10, ‘meta_key’ => ‘_last_viewed’, ‘orderby’ … Read more

Why is variable not working on custom sql query using wpdb?

Huge thanks to @kero !! I was finally able to create a solution by making the sql statement a variable first (as kero suggested) then using that variable on wpdb->query(); Here’s my updated and fully working codes now: $imdbid = $_GET[‘id’]; $string = file_get_contents(“http://www.omdbapi.com/?i=”.$imdbid.”&apikey=9a187152″); $json = json_decode($string, true); if( $json[‘Response’] === “True” ){ $dataID = … Read more

query_posts() ALWAYS displays something?

query_posts() ALWAYS displays something? No it doesn’t at least not for me, i’ve tried the code you posted inside my child theme and was unable to reproduce the issue described. Firstly, i tried… while ( have_posts() ) : the_post(); ?> <!— DO NOTHING ! –> <?php endwhile ?> ..and got nothing, so i then tested.. … Read more

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