"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.
0
votes
0answers
2 views
Query posts by Author and/or by Tag
I'm pretty sure I need to do some sort of custom query, but not sure about the best way to go with it.
I have an author page. It needs to display that author's posts. That's fine, I can do that. I ...
2
votes
0answers
21 views
How to implement time filter to show random post 1 month for one category and 3 months for other categories
I started to work on one website after another developer and there is problem with his "popular widget" which is basically showing 3 random posts from category. There is some Switch statement which is ...
0
votes
1answer
14 views
Displaying content to search engines but via navigation only for registered users.
Displaying certain information depending on if a user is registered is quite easy as I have been using this code
<?php if (current_user_can(‘subscriber’)) { ?>
[content here]
<?php } ...
-1
votes
1answer
25 views
query posts in wordpress
I want to filter my query results just before the_loop starts in word press. I only want the results having term_id or term_taxonomy_id equal to 1.
...
0
votes
0answers
25 views
querying on custom meta fields and sorting them by custom meta
I have event posts with multiple custom date and time fields.
To pull all the events happening this week, I am querying on the different date fields.
Here is my code:
$today=date("Y-m-d");
$nextweek= ...
1
vote
1answer
37 views
WP_query posts closest to todays date
I have written an wp query which I would like to order in a bit of a complicated way. Some posts have a meta value 'the_date' which is an end date for the post. I would like to order posts in date and ...
0
votes
1answer
22 views
displaying a fall back query if there's nothing in the post-type category
I'm stuck trying to figure out the best way to manipulate my query so that if there's nothing in the category it will display the latest post-type.
Here is the query I've got that pulls in the posts ...
0
votes
0answers
14 views
Wordpress $wpdb->query() inserts multiple rows with duplicate data
I am experiencing very strange problem with wordpress query() function.
I have a form on page 1 where below code to insert a new record.
if(isset($_POST["transaction_id"])){
global $wpdb;
...
0
votes
0answers
16 views
Create args for WP_Query using infinite scroll
I'm trying to use infinite scroll in my page as below.
http://phototravel.flop.jp/category/japan/mothersfarm/
All photos are actually custom posts under a category. It's using jquery masonry layout.
...
0
votes
1answer
8 views
Pull Instagram images into an existing loop?
I am looking for a solution to pull Instagram images (from a single account) into a Wordpress loop and mix them chronologically with standard posts that will have been created within the Wordpress ...
0
votes
0answers
23 views
Reduce number of SQL queries inside WP_Query loop to fetch author data
This question applies to scale and does not concern typical blog implementations. I'm working on a web app where I'm running standard WP_Query to fetch some custom post types. This usually results in ...
0
votes
0answers
20 views
Complex WP_Query Using Post Date And Post Meta
I am using Wordpress as a CMS on a website which has standard posts, a custom advert post type and a custom event post type. The event post type has some custom meta which stores the event start date.
...
0
votes
0answers
24 views
Search with meta_query and tax_query
I'm working on a little database for series based on wordpress. I've implemented a custom post type called "anime", some taxonomies (Genre, a_types..) and a lof of customfields. (based on acf). Now ...
0
votes
0answers
16 views
When importing a database any page with a wp_query in doesn't work
I've noticed this a lot, when I export a database from a test site and import it into a live site, any (or most) page with a wp_query in it doesn't show up correctly (It shows the theme, but as though ...
0
votes
2answers
32 views
Set conditional on template based on referring page slug
I have a portion of a page template that is conditional upon the following elseif
<?php elseif( isset( $wp_query->query_vars['details'] ) && $wp_query->query_vars['details'] == ...
-2
votes
0answers
33 views
Get all posts starting with first two letters in Wordpress
I have a plugin in which an alphabetical list is posted where people can click on a letter and they get the posts with that letter. So if they click on A, they see all post titles starting with the ...
0
votes
2answers
37 views
How to output comments number of a post per day?
I have a question about the comment numbers in a post... For now, I can output the total number of a comment inside a post outside the loop. That's cool enough, but I want to get show the comment ...
0
votes
0answers
20 views
Custom WP_Query for WordPress Search Results with meta_query
I am using a custom query to generate my search results. The code I am using works perfectly without the meta_query variables in my arguments array.
I am trying to compare multiple custom fields with ...
0
votes
2answers
46 views
How should I approach changing the template & $query as part of a shortcode's execution?
I am working on a project where I need to be able to change the template being used if a given shortcode is used. To complicate things more, the plugin must also be able to rewrite $query if this same ...
0
votes
0answers
30 views
Advise on Templates for Custom Queries
I'm trying to figure out the best way to solve this problem. I have a couple of archive type pages that display content from multiple post types at once. For example, I've overridden the default ...
0
votes
1answer
21 views
WP_Query meta_query by array key
I have a custom post type with its meta in an array. What I need to do is query based on the value of a key in that meta array.
$args = array(
'post_type' => 'my-cpt',
...
0
votes
0answers
30 views
Multiple homepage layouts as selected by user from theme options
I am working on a theme which will enable users to select multiple layouts from the theme options panel.
What I did so far is to create multiple theme files, depending on each theme, put it in a ...
0
votes
1answer
44 views
How to display WP Query filters?
I'm wondering if there is a way to display current WP Query filters. I wrote a function that is supported to delete all posts and it does but when I'm using WPML and it filters posts by language then ...
0
votes
1answer
38 views
Count posts returned by get_posts in external PHP script
I'm using WP from an external PHP script by including the wp-load.php file.
All functions and everything works as expected so far, except one thing: I can't get the $wp_query->found_posts to work ...
-2
votes
0answers
18 views
Problem with Creating a Custom Select Query with Custom Post Types
I am facing problem to join two tables one is wp_posts and another is wp_like_dislike_counters this table is created by using a plugin.
So i want to show all the posts which is liked by a user in a ...
0
votes
1answer
45 views
WP_Query of a custom post type isn't working
I am trying to WP_Query a custom post type. I would like to display the post_title s in a list. Here is my code, it doesn't seem to work:
<?php
add_action( 'init', 'custom_faq_type_mp' );
function ...
1
vote
2answers
38 views
Retrieving list of a custom post type in a widget without using WP_Query?
I'm using the following widget to retrieve a list of the custom post type jobs:
class FeaturedJobsWidget extends WP_Widget
{
function FeaturedJobsWidget()
{
$widget_ops = array('classname' ...
0
votes
0answers
43 views
Creating Advanced Search with text & Dropdowns
I am working to develop an advanced search option. Where there will be fields:
Text input Field (Post Title)
Dropdown (it will be a taxonomy)
Dropdown (it will be a taxonomy)
Basically I need ...
1
vote
1answer
35 views
Perform query with meta_value date
I am trying to perform a query on a custom-type post using the value of a custom field.
This field contains a string date: dd.mm.yyyy.
The post type name is 'event'
The custom field name is ...
0
votes
1answer
45 views
Custom query with category exclusion and post-meta “whitelist”
I have two widgets, one shows News while the other shows everything except News (We'll call the second one Blog). The blog portion is currently working correctly.
The News posts are either ...
0
votes
1answer
49 views
Filtering a WP_Query meta_query by numeric values isn't working
That was a very dense title.
I have a custom post type "event" which has a Date/Time picker field "event_date" thanks to the Advanced Custom Fields plugin. This Date/Time picker saves a UNIX ...
0
votes
1answer
31 views
Get Posts in a Custom Post Type category
I have trouble in getting post in a custom post type category. I have code below but it doesnt work well. It still get posts in another category.
<?php
$query= null;
$paged = ...
0
votes
1answer
51 views
WP_Query order custom post type with certain meta key value by post modified date
I have this query to show custom post type "property", and it works really well but the "orderby" statement, that is completely ignored...
$args = array(
'post_type' => CUSTOM_POST_TYPE1,
...
0
votes
1answer
28 views
Delete data from custom table when deleting a post
I want to delete post id form my custom table, when deleting a post. I have tried this way, nothing happened. Please help.
add_action('delete_post', 'delete_data');
function delete_data($post_id) {
...
1
vote
1answer
24 views
Reverse chronology of post listing
I"m working on modifying a theme that is based on 2010.
I want to make the posts on this blog display earliest to oldest, but I don't see how to do this in the theme:
I understand I need to add . ...
2
votes
1answer
48 views
WP_query : meta_key with custom rule for specific value
I'm a bit stuck with a WP_Query code. Here it is :
$args = array(
'post_type' => 'post',
'meta_query'=> array(
'key' => 'karma',
'compare' => '>=',
...
1
vote
1answer
19 views
If Query In Sidebar
I'm trying to create a query that
IF there is a value in the 'FeaturedQuote' custom field, then this shows
<h3 class="featuredquote"><blockquote><span ...
1
vote
1answer
42 views
Mysql query and order meta value
I made a mysql query to WordPress like this:
$querystr = "
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND ...
0
votes
3answers
37 views
Is there a way to make this kind of loop shorter and nicer?
Here is my loop code, i want to call different page templates for different pages. Please notice that this is a one-page-layout.
<?php $args = array( 'post_type' => 'page' );?> <!-- get ...
-4
votes
2answers
48 views
How can I display sticky posts at first in wp_query?
I'm looking for a long time, but I could not find a solution. I'm not a coder. Please help me. Here is my wp_query code;
$my_query = new WP_Query('category_name=animals&showposts=10');
while ...
0
votes
1answer
33 views
Insert data in custom table during new post creation
I want to in insert data in my custom db table when creating a post.
Suppose there are three categories (php, wordpress & jquery). When i create a post in wordpress, i want to insert post id and ...
0
votes
1answer
31 views
How does Show Posts based on a keyword search work in WP_Query
I am wondering how the search go through by defining 's' parameter in WP_Query.
For example if I have a post assigned to "East" term in taxonomy "Direction", the post didn't mention any "East" or ...
1
vote
1answer
94 views
Combine two taxonomies in a hierarchical tree
For example, I have WooCommerce products that have taxonomies:
brand (e.g. Converse, adidas, D&G) (taxonomy id: product_brand)
category (e.g. Boots, Sneakers, Sandals, Heels) (taxonomy id: ...
0
votes
0answers
47 views
Query recent posts by author
I'm fairly new to wordpress but trying to get recent posts by a specific author. The following code displays only most recent bog posts. I am using a custom field to get the author ID.
EDIT by ...
-3
votes
0answers
31 views
Pagination Issues
I've got a static home page with a wp_query for custom post type posts that need to be paginated. I'm using a page builder plugin to build the rest of the page.
I'm using the following code but the ...
1
vote
1answer
52 views
How to prevent execution of default query, while preserving ability to use WP_Query in template?
PROBLEM: I'am trying to prevent execution of default WordPress query for custom category template. I have found a possible solution, but looks like it preventing execution of all post queries:
...
1
vote
1answer
39 views
WP_Query returns more results than expected
I've written a query that is supposed to return all attachments called "no-image" (is part of a function that handle images fallback when there isn't a featured image), the if I get some result, the ...
0
votes
1answer
67 views
wp Query Posts to display in Nivo Slider
i have coded a slider into my wordpress theme to use query posts to display the thumbnail and the content however it appears that its displaying the whole posts? and not just the one relating to the ...
1
vote
2answers
48 views
Trying to find a way to query post like normal search would do. within search.php page
I have a costume search in a site i am making.
When a user search a certain term, i want to display category list with a count of how many posts are found with in that category.
I thought of a way ...
2
votes
1answer
43 views
Filter WordPress posts by between parameter
How to filter WordPress posts by a taxonomy and between parameter? Consider a mobile website with "memory size" taxonomy, I need to show posts that have more than 256 mb memory and less than 768 mb.
...

