Tagged Questions

"wp-query" ambiguously refers to one of two things. 1) WP_Query is a class native to Wordpress which allows users to query the posts database using a number of criteria. 2) $wp_query is the default object that holds the main query object on each WordPress page.

learn more… | top users | synonyms

-1
votes
2answers
25 views

How to modify this function to exclude also the post belonging to a specific category?

I am very new in WordPress development and I have the folglowing problem. I use this function (declared into the functions.php file of my theme) to modify the main query in such a way that the post ...
0
votes
1answer
159 views

Create new Wordpress post [wp_insert_post] based on results of a WP_Query

I have a a page where users can filter a list of custom post-type posts based on the "Ultimate WP Query Search Filter" plugin. Results are passed to a div on the page using AJAX from there users can ...
0
votes
2answers
179 views

Pagination/infinite scroll with WP_Query and multiple loops

I need that the main page of my site have 3 columns: - The first having the 5 most viewed posts; - The second with the next 5 most viewed posts; - The third with the most recent posts. I don't want ...
0
votes
0answers
88 views

Geo My WP automatically list posts based on visitor's location

Is it possible to affect the WP loop to automatically only list posts based on the visitor's location with the Geo My WP plugin? I'm creating a news site that will serve several towns and I'd like to ...
0
votes
0answers
60 views

Problem with correctly registering query variable

I have an admin page for my plugin, which lists records from database. I want to sort them under some conditions. To call different sorting options, I've decided to use query string. Step 1: At ...
0
votes
1answer
75 views

WP_Delete_user link creation

I am trying to create a user management via front end but i am not sure how to implement wp_delete_user Delete link add_action( 'wp_head', 'my_action_javascript' ); function my_action_javascript() { ...
0
votes
0answers
47 views

WP_Query, How to identify if the offset reached the max posts count

I'm doing a custom WP_query to populate my post list via AJAX with some filters. I load additional posts once the user click the 'Load More' button, this fires the $.ajax and on success adds the new ...
0
votes
0answers
52 views

Multiple Loops on a Custom Homepage

I have read many posts here and across web. I can't see why my loops return nothing (or the right query). Here is my code for multiple loops on a custom home page. Anyone know why my loops are not ...
0
votes
1answer
30 views

$args Orderby The number

I have this code $cat_args=array( 'include' => '42,210,21', 'orderby' => '42,210,21', 'order' => 'asc' ); $categories=get_categories($cat_args); foreach($categories as $category) { ...
0
votes
1answer
111 views

$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 = ...
1
vote
1answer
104 views

Using AJAX to generate front end / viewer end pages

I am currently trying to send certain data via POST method from code in the widget of my plugin to the theme's archive.php page. The code that contains the data for jquery/ajax is : <a ...
0
votes
1answer
31 views

Query function not executed between <div> element [closed]

I'm wondering why the following code is not executed between the element it's put in. I know sort of how to fix, but I'm not sure if that's the best solution. My code: First function function ...
2
votes
1answer
232 views

Some doubts about how the main query and the custom query works in this custom theme?

I am pretty new in WordPress theme development and I'm not so into PHP (I came from Java and C#) and have the following situation in this custom theme As you can see in the homepage I first show a ...
0
votes
1answer
26 views

Alternative to query->set that appends conditions instead of overriding

I am applying a taxonomy condition to the main query in my plugin which is excludes an array of post formats from it. It's being done as follows: $query->set('tax_query', array( array( ...
0
votes
2answers
57 views

How to orderby meta_value_num with dollar ($) sign

The custom fields all have prices including $ signs, and a dot as separator. $theQuery = new WP_Query(array( 'orderby' => 'meta_value_num', 'meta_key' => 'price', 'order' => ASC )); All ...
0
votes
1answer
122 views

Custom Search Query – include only custom fields and title

I have a custom post type and I also need a custom search. I want the post title and two custom fields to be indexed/queried. I found solutions for title only and for custom fields but not for both so ...
3
votes
3answers
169 views

Display posts the match taxonomy term linked from wp_list_categoies?

This should be simple, but it escapes me. I have a custom post type and a custom taxonomy. The taxonomy is named "asset_type" and the slug is "type" I am using wp_list_categories to provide a ...
0
votes
1answer
44 views

list posts of two post types in a single template

I have two post types. One is post & other one is event. Both sharing same categories & tags. I am listing the posts by archive.php. Now I am listing the posts as general by two different ...
2
votes
1answer
64 views

Including only current user's posts in search

I am a new WP plugin developer. I want the search page to include only the current user's posts. I first added a new capability read_others_posts to only administrators and editors. Then I tried the ...
0
votes
1answer
706 views

Woocommerce query all products and categories

I need to generate xml file from all my products. My current query shows all product names, but how to access categories for each products? All the products have categories and subcategories. My ...
0
votes
0answers
46 views

How to get specific records from table using multiple parameter

Bellow is my table structure wp_woocommerce_order_itemmeta meta_id order_item_id meta_key VALUE 1 2 Dining Date 2014-10-22 2 2 Booking Time 3:00 ...
0
votes
2answers
62 views

How do I order pages and categories by ID or name in the same query?

I would like to query most of my pages and categories on the homepage. So far I am able to get the pages and category (posts), but I cannot order the list the way I want to. I want to be able to get a ...
0
votes
0answers
54 views

Comments pagination and WP_QUERY

I have a list of posts using wp_query On each post theres a list of comments What Im trying to do is to limit the number of comments to 2 and display a link for the next page of comments which I'm ...
0
votes
0answers
59 views

Sorting meta_value as integer doesn't work

This plugin uses the below chunk of code to print the top 10 highscores. But this doesn't get the list of top 10 scores sorted by meta_value in my WP install $scoreboard = new WP_User_Query( array( ...
0
votes
1answer
75 views

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 ); } ...
1
vote
2answers
72 views

Query that loads a custom type AND posts whose ids are not inside those custom types custom fields

On my news website I have posts and another custom type called "aggregato". This type has 10 custom fields, "link01", "link02"... "link10". Both posts and aggregato has a meta key, called "home", ...
0
votes
0answers
72 views

Fire query on ajax post url page

Here i am sending the ajax response to load_post.php page from my ajax call.I am getting response on load_post.php on load_post.php i have to fire word press query. I was try this but getting bellow ...
3
votes
1answer
222 views

How can I reduce the number of database query calls for this custom homepage?

I am working on the design of a blog with the below(just a sample) category hierarchy. PARENT | ...
0
votes
2answers
94 views

WP_Query issues with argument posts_per_page

I have a query that displays the names of donors as well as a dedication. It displays using a date meta query. $args = array( 'post_type' => 'donors', 'order_by' => 'id', 'order' => ...
0
votes
0answers
58 views

How to organize a WP_Query's list of posts by category and display category title?

If I run a query with some args and get a list of posts, how can I organize the posts separated by category and display the title of each category? $array_out = array(); $args = array( 'orderby' ...
0
votes
1answer
38 views

$wp_query when new WP_Query

I'm trying something but I have an issue with WP_Query. I've an Hook on the_post in order to add some variation on the query. add_filter('the_posts', 'query_variation'); function ...
0
votes
1answer
218 views

Remove duplicated values from a loop

I have a loop that outputs <option> fields for a <select> group. It contains many cities' names for many travel packs that I am publishing. The trick is that I need avoid repeated values. ...
0
votes
0answers
38 views

Get a list of the last posts grouped by author and filtered by category

i need a list of the latest post published by various authors, but filtered by category, like for example the latest posts of author that write about music. i wrote this query and looks like working ...
0
votes
2answers
217 views

Loop through categories and create tab for each

I'm trying to create a page that holds all categories of my custom post type as tabs, with a tab content. I am able to display all the category names as tabs, but i need to run a query in each tab ...
0
votes
1answer
197 views

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 ...
0
votes
1answer
85 views

Sticky posts are not showing at the top of category posts

Can anyone tell me why sticky posts are not being displayed at the top of the following query: $wp_query = new WP_Query(array( 'post_type' => 'post', 'posts_per_page'=>10, ...
1
vote
2answers
45 views

Most commented post should be the first post in the blog

WordPress default setting is, most recent post is the first post of the blog. But, I need to "Most commented post should be the first post in the blog". ( Categories page as well as home page)
2
votes
2answers
297 views

Determine WP_Query parameters from URL

I'm wondering if it's possible to determine WP_Query parameters by only using the given page URL. The reason I'm trying to do this because I'm developing a SPA theme (and ultimately a JSON response) ...
0
votes
1answer
17 views

Issue with data array format

I am trying to fetch a record of date from table booking_history with bellow code but the result array not displaying any record from start_date column. when i echo the query query displaying value ...
0
votes
3answers
84 views

How to select posts from one category but exclude posts in another category?

I am trying to select posts that have category id 4 but exclude posts that also have category id 2 Here's what i'm trying $query = new WP_Query(array( "cat__in" => array(4), ...
0
votes
1answer
90 views

Pagination doesn't function properly for archive of a custom post type set as the front page

I created a similar question about an hour ago but since then I feel that I've changed things enough so that if someone viewed it for the first time, it'd just be a confusing mess. So I am opening up ...
0
votes
0answers
67 views

Pagination not working in some author pages

I have an author archive page to display authors' posts. In some of the authors the pagination works, but in some cases it doesn't. Where is the problem? Here is my code: <?php $paged = ...
0
votes
2answers
68 views

Pagination custom query

I am trying to make a custom page template that shows the most viewed posts. I can return posts but I am having trouble figuring out how to paginate it. Here is what I have: $args = array('orderby' ...
0
votes
0answers
56 views

Search form not working on page templates

I have this on my searchform.php: <div class="search searchform" role="search" method="get" id="searchform" action="<?php echo home_url(); ?>"> <form action="#"> ...
0
votes
1answer
49 views

Query only the posts with a post format of “audio”

I'm trying to query only the posts that have a post format of audio. I'm pretty sure I'm doing this wrong. Can I get a little help? <?php get_header();?> <section id="content"> ...
0
votes
0answers
123 views

Passing query variables to a custom page template

On my website I have a custom post type called 'theme'. I wanted the homepage to display an archive of themes. For this the only approach that I could think of was to create a page template with a ...
0
votes
1answer
39 views

How to Query Updated Post in WordPress

I have seen some website which are showing the updated post. How can I query updated post from database. please help me thank's
0
votes
2answers
101 views

Custom WP_Query not working correctly

OK, So I have created a custom WP_Query that gets the post_type post and outputs it as a styled list. It works well and outputs the styled list but then underneath it displays all the posts again but ...
0
votes
0answers
72 views

WP_Query Sorting Posts by month … timeline effect

Hoping someone can take a look at my code and help me out. Right now I am trying to show my blog in a timeline style approach. My current query is generating the posts how I would like them to but I ...
0
votes
1answer
34 views

How to query the custom fields by language?

For each post, there is a custom field name "Function", the key/value pair is like this: Key : Functions Value : <!--en-->Nourishing Yin and invigorating the vital essence of ...