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

learn more… | top users | synonyms

0
votes
0answers
109 views

Marginal pagination on home.php

I'm trying too make a custom wp-theme and use a few loops in home.php. But now I can't finish home.php because of pagination. How cant I realize any type of pagination with saving that kind of ...
0
votes
1answer
343 views

How to add a prefix to existing custom fields over MYSQL query?

I've got the problem that after a plugin update I can make the custom fields on our directory site searchable, but only custom fields which get the prefix booking_ to them. Now there are some pages ...
0
votes
2answers
35 views

Find all posts via SQL beginning with A of type B

I have problem with post and taxonomy query. What i need is to get all post's from custom post type which starts with A and have defined term. Here is my sql: SELECT * FROM $wpdb->posts, ...
0
votes
1answer
39 views

How do I add tags/taxonomy to images + a query field on page to query 'albums' (images with same tag/taxonomy)

I've got lots and lots of photos on my site and I want to seperate them into albums. Every album is a client album (photoshoot). Though.. I want all my clients to query their album on my site. ...
0
votes
1answer
52 views

Show links to child pages on both parent AND child pages

I have a client who wants the following; They have a series of pages, each of which have children. On the parent pages they want to show links to all the children. For this I am currently using this ...
1
vote
1answer
691 views

WordPress Loop: List All Posts by a Category & Subcategory

I want to display all post under a category and all subcategories under the parent categories. But couldn't find proper suggestion over forum or failed to understand the solution. It's possible to ...
0
votes
1answer
49 views

Checking for existing title in custom db query not working

I want to check if the title exists before the wp_insert_post() is triggered. However, the condition seems not to work as expected: if( $wpdb->get_row("SELECT * FROM wp_posts WHERE post_title = ...
-1
votes
1answer
139 views

Multiple loop with pagination in same page

In my home page i have two <section> in which i perform two different loops on different post categories. Here the code: <section> <ul class="loop-article"> ...
0
votes
1answer
127 views

List of buyers for each product

I would like to know if it's possible to get the complete name of each buyers for a specific product or the orders list of a specific product ?
2
votes
1answer
277 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
111 views

Best practice to limit results in get_row()?

This is my query to check if a title exists (it's in a loop, therefore [$i]). $wpdb->get_row("SELECT * FROM wp_posts WHERE post_title = '" . $titles_arr[$i] . "'", 'ARRAY_A'); Anyway, I would ...
0
votes
1answer
65 views

Post content stays the same but permalink changes ?

This is really weird. I made a posttype ' mediagallery ' via the plugin Types fields. I simply want to load the post content and switch the posts with a next & prev button in de sidebar. The post ...
1
vote
2answers
748 views

How to write: $wpdb->update having WHERE NOT value pair in the array

I need to update all meta keys in the postmeta table that have a value other than 0, to the value of 0. I tried this.. no love (though I cannot figure out why....): $status = $wpdb->query("UPDATE ...
0
votes
0answers
145 views

List number of posts with a specific meta_key for each meta_value

I would like to list my posts by a specific custom field. At the same time, for each custom field, I would like to count the number of posts with a specific custom field value. I have a custom field ...
0
votes
0answers
133 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
1answer
98 views

Adding an orderby filter, casting postmeta with multiple keys

I am using this filter to sort my query by a date field stored as text (legacy data) add_filter( 'posts_orderby', 'my_posts_orderby_date', 10, 2 ); function my_posts_orderby_date( $orderby, $query ) ...
0
votes
2answers
496 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'] == ...
0
votes
1answer
201 views

How can I get the name of term post meta value which equals term id

I have a custom taxonomy (location) that is being populated automatically by an advanced custom field on user save. The issue is that it saves the term_id in the postmeta meta_value field. When I echo ...
0
votes
1answer
200 views

Exclude all sticky posts front page twenty twelve

I am attempting to exclude all sticky posts from my front page in twenty twelve theme. I have attempted the following. I am making all changes to the child theme. To remove the following code from ...
2
votes
1answer
493 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
0answers
98 views

Pre Get Posts fails with more than 1 Post Type

Inside Functions.php function custom_filings_archive( $query ) { if(is_post_type_archive( 'filings' )) $query->set('post_type',array('the-reports','press-release')); return $query; } ...
1
vote
2answers
232 views

Disable the MySQL query in the main query

I would like to disable the MySQL portion of the main query, i.e. I want every step to be followed on this page EXCEPT step 4.3: http://codex.wordpress.org/Query_Overview What's the easiest way to go ...
0
votes
2answers
578 views

How to display only one category in a custom post type?

I have a custom post type called 'portcat' and I want to display the results of only one portcat category ('games' - which has an ID of '3') on my page. The below code displays all of the categories ...
0
votes
0answers
98 views

Retrieve post data via WPDB class

I'm trying to figure out doing a custom query using the $wpdb Object. I have custom type posts, event_posts, that have meta data, images, as well as event dates which are input in the post with the ...
0
votes
2answers
2k views

$wpdb returns no results with SELECT query on custom post type, works on default post type

EDIT: Adding more background info. I've coded a plugin that adds a meta box to the post page. When the post is published, the plugin will generate a random ID for the post, and insert the random ID ...
0
votes
0answers
127 views

How to exclude 2 Portfolio Categories from page?

I want to exclude 2 Portfolio categories (IDs 4 & 23) from a page using the code below but it still displays all categories. Similar code works for 'Posts' but not for 'Port' - can anyone see what ...
0
votes
1answer
116 views

add_query_arg to look up page title

I'm trying to get the code below to look up the status name, i.e. new, open, pending or resolved with the word ticket together to find pages called new tickets, open tickets etc. $ticket_status = ...
0
votes
0answers
96 views

get_query_var('paged') giving same result

I have a custom page, in that page i am using a custom select query for my search functionality. The problem is pagination not working. I used $on_page= get_query_var('paged'); for pagination. When ...
0
votes
0answers
162 views

The offset option breaks the pagination

I have a problem with a website of mine, I was hoping you can help me. I added the offset option to ignore the first couple of posts in the main loop. It does its job, but the navigation got broken. ...
0
votes
1answer
73 views

How do I query for posts by custom meta and those that have been stickied?

I realize how clumsy and inefficient this query is but SQL is not my strong point. I use the following query to pull the latest 8 events from a custom post type called Event Posts. However, I also ...
1
vote
2answers
910 views

Specific Loop For 2 <div> Within Each <li>

I need to create a loop that can logically be described as the following for a carousel: Requirements: 3 Loops 2 Posts Per Loop No Duplicates Order by Post Date Visual: < Start Loop #1 > ...
0
votes
0answers
33 views

Listing custom post type items from a couple of custom taxonomies

I know I have asked a similar question in the recent past (Listing all custom post types using a specific term on the said term's template page, in groups), but in this case, the template is more ...
0
votes
0answers
138 views

Custom query on Wordpress custom table

I am working with a custom table where some values will be inserted or updated if they already exists, I have checked and rechecked the syntax and it seems to be working fine, if I run the same query ...
0
votes
1answer
195 views

pre_get_posts : 'post__not_in' doesn't work with global variable

I'm trying to set a post__not_in which use a global $popular variable, defined in the index.php. -index.php- $popular[] = 1 //post id=1 $popular[] = 2 //post id=2 $popular[] = 3 //post id=3 ...
1
vote
1answer
120 views

wpdb query problem to access previous 3 days posts

I am trying to get all published posts titles by author id 2 most recent by post date for the last days. Here is my query: "SELECT post_title FROM $wpdb->posts WHERE post_status = 'publish' AND ...
1
vote
1answer
212 views

Admin Posts List (edit.php) by post IDs

I'm writing a plugin that creates posts in bulk. I provide a way for the user to set certain parameters of the created posts beforehand. But it would be useful to use the WordPress default "All Posts" ...
0
votes
1answer
49 views

Different layout based on post amount?

Is it possible to change the layout of the query posts depending on how many there are? So simple query page listing posts... Up to 4 posts show them in a list. If there are 4 posts and over show ...
0
votes
0answers
122 views

Special Query: Title, Terms, Content - %LIKE%

I'm working on a them theme that is search-heavy, and my users are putting huge priority on an improved search function. I think I will have to use a special direct query to search these things: ...
-1
votes
1answer
95 views

query_post or single-[cpt].php?

php query_posts( 'post_type=listing'); Or single-listing.php? According to my reading I have presumed that to display a custom post type all I need to do is copy my single.php and rename it ...
0
votes
1answer
471 views

PHP variable in WordPress database query

When running the following code : $voucher = 'MK0186'; $is_in_database = $wpdb->get_results( "SELECT * FROM my_codes_table WHERE code =" . $voucher ); I get : WordPress database error: [Unknown ...
0
votes
1answer
443 views

Select min/max meta from query

Kind of lost on what to do here. I have a meta price for each post. I'd like to get the min and max price meta values of this search/query. At the moment its returning the min max values for all ...
0
votes
0answers
54 views

Displaying posts by year

I'm trying to display posts on the homepage from the current year only. I am using the following: <?php if ( is_front_page()) { ?> <?php $current_year = date('Y'); ?> <?php ...
0
votes
1answer
82 views

Query for first 3 posts to change the look and feel

Is there a way to query for the first three recent posts and then change how they display on the front page? I want the first three posts of my blog to show differently than the rest of them i.e. ...
0
votes
1answer
159 views

Better wordpress attachment query then this

I have a site with more then 10.000 posts and images, its classipress site. I need somehow to show all images from posts that are on pending status, and who havent expired(post meta). This is the code ...
4
votes
1answer
1k views

Changing the meta_query of the main query based on custom query_vars and using pre_get_posts

I've registered custom rewrite rules and query_vars to use for displaying a list of events based on ISO date format. For example when a user requests the URL, http://site.com/by-date/2013-04-04/, my ...
0
votes
3answers
662 views

How to delete all posts, categories and tags from Wordpress database

I have WP website with over 40,000 posts. Now I'll like to delete all posts, categories and tags. So All content and related meta. All I want to keep is static files. Is there a easy way to do this ...
0
votes
1answer
323 views

wordpress category.php query for featured news item, broken pagination and repeating posts

I am having a few issues with a site I am building, on the news page It has 1 featured post from the news category and then under that more news category posts, but missing out the featured news item ...
0
votes
1answer
342 views

How to customize a title by passing query string?

I have a profile page, it is a template. Every time when I click one of a doctor, the profile page will show the specific doctor info by passing a query string. Something like profile?doctorName=abc. ...
1
vote
2answers
151 views

How to List Parent Term Links for Custom Taxonomy With & Without Children?

I have a Custom Post Type of "projects", that is categorized by a Custom Taxonomy of "industry", which is heirarchical. Projects & sub-projects are assigned to the industries. For Example, the ...
1
vote
1answer
166 views

using post__in allow duplicate post id

I have an array of ids in a specific order. I use post__in in my query to get posts from this array. I have some duplicate post IDs that I need to show twice in the page but the query seems to ignore ...