A generic term referring to the process of retrieving information from a database.

learn more… | top users | synonyms

2
votes
1answer
277 views

Save default value for empty or missing post meta

I am using WordPress and I am using a custom field that has the name ecpt_carprice for each post I am publishing, the field is saved in wp_postmeta the same as the attached image: Some of my cars ...
0
votes
3answers
1k views

Get wp_get_attachment_url outside of loop

I need to get the featured image outside the loop. This is so that I can have a different full-screen background image for each page, set by the featured image. After doing some research I was able ...
0
votes
1answer
56 views

I am officially missing something about transient posts

I have no issue creating transients. What I have an issue with is pagination - and I have made posts on it before and every one sates that the query must look like, for example: $queried_post ...
0
votes
0answers
52 views

Multilingual Wordpress page - using URL to determine language?

I want to create a webpage that supports more than one language, but I don't want to use a plugin for that if it's possible. I am already loading the theme translation depending on the URL; if ...
0
votes
1answer
60 views

Category slug in in loop always the same?

My post category structure is 3-level deep: Products Milk products Milk Chocolate Cheese I want to show all posts from "Milk products" and add appropriate category slug as class, for example ...
0
votes
1answer
147 views

How to store post rating system data post independent?

There's code below for simple post rating system (tutorial from this site TUTORIAL ) - it works fine but i need to change it a bit. Now where user votes, he is not able to vote again for same post for ...
0
votes
1answer
45 views

search meta field for a value in all posts

Hi I want to search meta field for a value in all posts. Code below shows what i want to accomplish (im wp and php beginner and cant manage to make it work by myself). If in meta field "voted_IP" ...
21
votes
1answer
14k views

How to fix pagination for custom loops?

I have added a custom/secondary query to a template file/custom page template; how can I make WordPress use my custom query for pagination, instead of using the main query loop's pagination? Addendum ...
0
votes
1answer
305 views

Select column name dynamically mySQL Query

$country="USA"; $dr=$wpdb->get_results("SELECT $country FROM wp_shipping WHERE ID=$ids"); I want the above query in WordPress file, where country name is given dynamically but I am not getting ...
0
votes
1answer
50 views

Query pages based on tags

On a site that I'm working on I've added the ability to tag pages. These tags should then be used in a query to retrieve all associated pages of a tag. In my functions file - // Add tag support to ...
0
votes
0answers
132 views

Join two wp_query

So, i have custom posts with this settings: Example 1: have meta_key "price" Example 2: have meta_key "no_price" So, i want to list this posts ordered by "price". I just want to join these two wp ...
0
votes
1answer
267 views

Insert images into wordpress post with a query

I have a Wordpress installation with 2.000 posts. Also in a separate table of my database I have a set of image paths and the filenames of the images, each image is assigned to each post of my ...
1
vote
2answers
61 views

Querying Term Posts in Loop

I'm trying to show my CPT Category along with any posts associated with it below the title. I have the first loop fine: <?php $cats = get_categories(array('taxonomy' => 'custtax', 'orderby' ...
0
votes
1answer
65 views

Filter posts by author selected in page

I've inherited a Wordpress project, and my client has a new feature request. For a "portfolio" page template, they want to be able to select an author, which I want to add to the $args in my ...
0
votes
1answer
114 views

Meta Query for specific months

I have a custom field which stores a date in a timestamp. I want to run a query that display posts based on the month, for example all entries from March, the specific day or year doesn't matter. I'm ...
1
vote
1answer
77 views

if/else on custom query gives 200 OK when condition not met?

What? I am modifying my theme to show comments of a post on a separate page. How? Mostly based on this answer but with improved checks and code. So this is what my page-comments.php (kinda) looks ...
3
votes
1answer
224 views

Using Wordpress public query variables

Good morning. I am trying to query various Wordpress pages, using public query variables, for example http://dmkim1979.ru/?p=37 // single post http://dmkim1979.ru/?page_id=40 ...
1
vote
1answer
38 views

How can I get a list of comments by target

I've been looking at the classes WP_Comment_Query and WP_Meta_Query but to be honest, I can't figure out how to use them together. I want to query the database for comments where wp_posts::post_author ...
0
votes
1answer
666 views

date_query seems to be ignored by wp_query

I'm altering my main wp_query in a pre_get_posts filter in order to improve my site search capabilities. I've successfully achieved searching in taxonomies, but I fail when it comes to the post date ...
0
votes
1answer
169 views

Making certain categories of CPT not publicly queryable

I am developing a custom CMS for a client and one of the Custom Post Types is 'contact', these contacts are organized into categories by a custom taxonomy; my question is whether there is a way to set ...
1
vote
2answers
371 views

Sticky post appears twice

I am trying to modify the number of posts_per_page in the loop. This way: function posts_per_page($query) { $query->query_vars['posts_per_page'] = 3; } add_filter('pre_get_posts', ...
0
votes
1answer
93 views

Exclude taxonomy term from all loops, but having it on widget

I have excluded a custom post type taxonomy term from all posts like this: add_action( 'pre_get_posts', 'exclude_category_posts' ); function exclude_category_posts( $the_query ) { $taxquery = ...
0
votes
1answer
1k views

Select User by Joining Multiple Meta Value Results

( I would ask this in the general stack exchange forum but I think it is more relevant here. I'm intentionally using direct queries to the database here. ) I'm trying to select a group of users that ...
0
votes
1answer
34 views

How to rearrange a pool of posts joined using two queries?

I need to select posts for two different months (current, past). As far as i know, it is not possible to pass m date parameter as an array of integer instead of an integer, so I am performing two ...
0
votes
1answer
134 views

how to limit query_post to first page?

I have a custom post type called listings with different taxanomies, I am using this query to display first only my post that have the type taxonomy featured. This is the code that does that : ...
1
vote
1answer
189 views

How to go about combining dropdowns / filter queries?

I'm coming up short with my googling here. (As 'filter' in wordpress always turns up more content related info). Anyway, my situation is this: I have Categories, Tags, Authors and Archive dropdowns ...
0
votes
1answer
205 views

do_shortcode within post query

I am querying blog posts with a specific category (according to the template page slug, and want each post to output a slider, title and content. I'm using the wordpress plugin Anythingslider for ...
1
vote
1answer
202 views

Attempt to improve WP search, can someone check my SQL query?

I'm stumped. I've done a bunch of work to filter what posts get pulled in a WP search and then even more work sorting those after they're pulled from the DB. My main problem now is getting results ...
0
votes
1answer
224 views

Filter Posts by current Month

Ok, I have a client that wants to only display posts by the current month. I've tried a few different variations but none have worked. Here's where I'm at now. Any help is appreciated! ...
1
vote
1answer
116 views

Transient pagination not working properly

So I wrote the following to create a transient: $wp_object_i_created = new WP_Query('cat=1'); set_transient('category_one_posts', $wp_object_i_created, 60*60*1); Ok so then I decided "Ya know lets ...
3
votes
1answer
218 views

Why does wordpress still strip my query var?

Im trying to pass a query var to a custom page template with pretty permalinks. So basically i have a page called "albums". And i want to pass a query var to that page called "type". So the ...
0
votes
3answers
636 views

Dynamically switch template on click

I have a custom post type setup with a couple custom fields. I am creating a page where I display all of the custom post types, except I want to have multiple views. See the examples below. One is a ...
0
votes
1answer
309 views

Random Category with Recent Post Title and Thumbnail

This code below works perfect to pull the title of five random categories, the issue is for each random category I want the latest post title and thumbnail but where and how do I add the post query? ...
1
vote
1answer
209 views

How to debug a blank page?

I'm not being able to load this page, although I can easily load all other posts that load the same custom post type template (please look for "// From now on, WP is throwing a blank page" on that ...
0
votes
1answer
54 views

Wordpress Query showing multiple titles

I have written a query to display in a jquery slider (nivo) however it appears that it is showing all the posts and not just one at a time This is my code: <div class="slider-wrapper ...
0
votes
4answers
489 views

Query Posts by date range with fixed beginning and end

I need to get posts from a certain timeframe. I am using the posts_where filter. I want to specify a beginning date and an end date. This is the function I use: function filter_where( $where = '' ) ...
1
vote
1answer
201 views

Undefined WP_Query::has_posts()?

This must be wrong. I was testing something so I did: $queried_post = new WP_Query(array('posts_per_page' => 5, 'offset'=> 1, 'category' => 1)); var_dump($queried_post->has_posts()); ...
0
votes
2answers
481 views

Wordpress Find Duplicate Post By Content

Is there any way to find similar/duplicate wordpress posts by post_content. I have tried "Find Duplicates" plugin but it takes a lot of time to search since I have more than 7000 posts in my ...
0
votes
1answer
106 views

custom query to get posts

I want to create custom links like mydomain.com/custom_page/cat=ABC&tag=XYZ So that when a user clicks on the link s/he can see all posts in the category 'ABC' having tag 'XYZ' For this I've ...
3
votes
3answers
280 views

Compare two numeric custom fields

I use Advanced Custom Fields and have a custompost-type "matches". This post-type contains two fields "goals-made" and "goals-against". I want to query wordpress to show only the matches that were ...
0
votes
2answers
505 views

Passing parameters to a static front page

I have googled a lot, but so far haven't come close to a proper solution yet. I need help with passing parameters to the homepage of a WordPress website. Here's my setup / requirements: I use a page ...
0
votes
0answers
18 views

Query posts than have a lapse of time active

First of all, sorry guys for my poor english. OK, i wanna make a query for show posts that doesn´t passed 3 days from it publication. I set a field for the expire date when it´s published (the time is ...
0
votes
3answers
1k views

how to get a different html for odd/even posts?

query posts if posts exist then begin the loop if post is even: <h1>title</h1><p>content</p> if post is odd: <div>its ...
0
votes
1answer
483 views

Why doesn't my WP Meta Query return any results?

Is it not OK to accept a value from $_GET as the key in a WP Meta Query? I'm not sure why this code doesn't return any results... BOTH the queries for Price as well as bedrooms do not return any ...
1
vote
0answers
77 views

Caption and title in img alt tag are the same?

I'm currently on WP 3.6 and noticed an unpredictable behaviour with the alt attributes generated by WP. If I have an image title, the title appears in the alt. If I have a caption, the caption ...
0
votes
1answer
436 views

Can I use WP_Query one time and then filter the results multiple times

I am using the following code 20 times in one page template to query specific data for each section. All of the pages data comes from the same post type, just I need it divided up by a specific custom ...
0
votes
1answer
71 views

Displaying Posts Attached to Custom Taxonomy Terms

The following displays a parent term in a custom taxonomy, then displays the child terms and finally is intended to display the post links (custom posts) for the posts attached to each term. Thus: ...
0
votes
1answer
39 views

how do i register global query in template

ok i think this is a basic php question but here goes: i have this working code: <!-- show the bands playing --> <?php $child_posts = ...
0
votes
1answer
14 views

Custom Query problem access the values

Below is the custom query am running on my wordpress site to get the results from postmeta table. When I var_dump the results then I can see the values correctly but when am trying to access a single ...
0
votes
1answer
329 views

Update Custom Taxonomy Value for a post based on custom date field

Quick read: I need to update the value of a custom taxonomy based on two custom field values (dates) automatically, meaning the post updates itself with having to click "update" to change the value. ...