Articles of wp query

Displaying Event within two given time frames

I’m trying to display two different posts from my CPT named Events. One is going to be the next event the other is going to be previous event. I’ve got a metabox called ‘Event date’ The client at the moment places the date of the event in here. I’m thinking of somehow using this date […]

Remove Post if Advanced Custom Field is checked to fix paging

I’m trying to setup a query that filters through posts and removes ones that have an ACF field “archived” checked. Post queries are pretty foreign to me. query_posts(“cat=10&posts_per_page=12&post_status=any&order=ASC”.”&paged=”.$paged); How can I edit that string to check to see if the post has the archived checkbox checked? This is how I’m currently doing it, but because […]

$wpdb select date range of posts

0 down vote favorite Using this SQL query to sort users by how many votes(meta key) their posts have received. <?php global $wpdb; $results = $wpdb->get_results ( ” SELECT u.display_name as name, ( SELECT SUM(pm.meta_value) FROM wp_posts p, wp_postmeta pm WHERE p.post_author = u.ID AND p.post_status LIKE ‘publish’ AND pm.meta_key = ‘epicredvote’ AND p.ID = […]

localizing variable on front-page.php template fails but succeeds on single page and taxonomy archive

I have the following code in a php include file: function pass_the_var() { $video_embed_code = jkaw_oembed_code(); return array( ’embedCode’ => $video_embed_code ); } earlier in the same file I also enqueue my scripts: wp_register_script(‘jkaw-js’, get_template_directory_uri() . ‘/lib/js/jkaw.js’, false, ‘1.0’, true); wp_enqueue_script( ‘jkaw-js’ ); wp_localize_script( ‘jkaw-js’, ‘phpVars’, pass_the_var() ); I am using this code on a […]

Query outputting YouTube url rather than embedded video

I am having an issue with a query outputting the YouTube url rather than the video itself. The post I am querying has a Youtube url in the content area. Of course, when viewing the post, you don’t see the url, you see the video, as it’s supposed to be. When using get_the_content to display […]

wp-query, pull children of parent page

So here’s what I’m trying to do: I’m trying to develop a theme that shows any sub-pages on the parent page. I’ve gotten this running successfully with a WP_query and a simple loop: <!–show sub pages on this page–> <?php $childargs = array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘page’, ‘posts_per_page’ => ‘-1’, ‘orderby’ => ‘menu_order’, […]

How to display posts from multiple post type in random order in wordpress?

I want to display posts from multiple post types (photo, post), with one post from “photo” post type and another post from “post”, in the same loop. Can anyone help me? Here is my code: <?php $args = array( ‘post_type’=> array(‘photo’, ‘post’), ‘orderby’ => ‘date’, ‘posts_per_page’ => 10, ‘paged’ => get_query_var(‘paged’), ); $query=new WP_Query($args); if […]

WP_Query order result by date AND meta_value

I have searched but not found an answer to my problem. I have posts with a meta key used for ordering. I want to order post by this value. If they have same value I want them to be ordered by date. I guessed that this was the query to use: new WP_Query( array( ‘post_type’ […]

I need to run a AJAX Fuction from within a WP_Query but only works on first item

I have a page where users filter results from the Ultimate WP Query Search Filter plugin. The results are shown in a DIV via an AJAX call. This is working 100%. However I have another AJAX function attached to each result in the query allowing users to create a new post from search results. (See […]

Custom wp_query – I'm getting 'all' post, not the specific post in the query

Get all post from today, that are of post type ‘product’ and are in the taxonomy of ‘productType’ as ‘Indica’ and in the taxonomy of ‘locationCity’ as ‘Los Angeles’ — However, I get ‘all’ the post with no regards to the query params of the custom taxonomies. // args $today = getdate(); $indicaArgs = array( […]