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

learn more… | top users | synonyms

1
vote
1answer
435 views

Disallow categories from this MySQL query

I'm trying to modify a plugin that generates an archive listing so it shows only one category, making it a single category archive. The old version of the plugin used a get_posts query, and so it was ...
0
votes
1answer
57 views

Listing posts by grouping dates

I have a music events site http://www.zarpa.eu. I'm using the Future is Now plugin to help me to schedule the events http://wordpress.org/extend/plugins/the-future-is-now/ I'm trying to group ...
0
votes
1answer
143 views

Page displays content from different query?

How can I reset all variables in order to get the actual page content? I keep getting the last post's content I've called from a news-box I've implemented - but need the actual page's content .. ...
1
vote
2answers
5k views

Does meta_query work within get_posts array?

I can't seem to get this to work — I'm trying to show posts that have the meta 'featured_image' value set to anything. From what I can tell, it's set up correctly, but I'm in a little over my head. ...
0
votes
3answers
709 views

Each post is showing twice in my custom query…?

I've created a custom query to pull all posts from a custom post type, ordered by comment count. It's your run-of-the-mills custom query: <?php $querystr = " SELECT wposts.* FROM ...
1
vote
4answers
4k views

Export wordpress table to excel

I have created PHP scripts before to export a database table to .xls format like this: $select = "SELECT * FROM tracking"; $export = mysql_query ( $select ) or die ( "Sql error : " . mysql_error( ) ...
1
vote
2answers
1k views

Count how many posts have a custom field set

I've added some code to my templates which automatically adds custom fields to cache some data that each post pulls in. Is there a way that I can track how many posts have had this custom field set?
1
vote
2answers
902 views

Selecting New & Edit Page for Custom Post Types

I'm probably missing something unless it's really not possible, for some reason I can't get my function to only execute on the new and edit page of a custom post type (the new not being a problem): ...
0
votes
3answers
852 views

How to find if a post with custom_field == X exists?

I need to find if a post with a custom field X equal to Y exists in a wordpress installation. Should I do it with a simple sql query or is there something build in that can help me achieve it?
2
votes
3answers
3k views

Custom Select Query with Custom Post Types

Have been trying to figure out the issue with this for the past hour, but hitting a wall. Basically I'm just trying to query my custom post type based on some custom date fields and then displaying ...
-1
votes
1answer
1k views

WP insert post PHP function dynamically generated Custom Fields

Further to my previous question WP insert post PHP function and Custom Fields We have a working insert post function that can also send over custom fields without yet knowing the ID. Please see the ...
4
votes
3answers
3k views

Optimize Multiple Taxonomy Term MySQL Query?

(Moderator's note: Title was originally: "query/database optimisation") I'm written a function for a custom "filter" search panel that allows users to select terms from up to four custom taxonomies. ...
0
votes
1answer
925 views

Query of custom post types only shows first post

I have a loop to show my custom post type of 'case_studies'. It originally showed all posts until I wanted to just show 3 specific posts. The problem is that it only shows the first post in my list of ...
0
votes
1answer
428 views

Custom query for custom post_type

I need to display a list of current tasks. Each task has a custom post_type and a start date and end date. Can someone tell me how to modify my query so it will pick up any tasks that have a start ...
0
votes
1answer
153 views

pre saved posts query from db options table

I found a question about magazine style front pages that queries always only 1 post (or custom_post_types, etc.) from a whole load of different categories, tags or custom taxonomies. I thought about ...
0
votes
2answers
340 views

How to get events using multiple custom meta fields?

I need to grab a list of current events. The events have a start and end date so I need to be able to select a range as opposed to just getting any list of events that have an end date that is after ...
1
vote
4answers
3k views

How to tell if $query_var isset?

I tired to use isset($queryvar) but that didnt work, so I implemented my own function qv_isset, but it runs into a problem when $ch is set to 0. $cls = get_query_var('cls'); $ch = ...
10
votes
8answers
51k views

What SQL Query to do a simple find and replace

Whenever I create a new website I first create a staging site on a subdomain like "stage.domain-name.com". After everything works correctly I export the database, open it in notepad++ and do a ...
1
vote
1answer
3k views

Overriding default calendar to show posts from a category

I'm trying to modify the default WP calendar (get_calendar()) so that it shows posts from a specific category and then use that as a shortcode. Here's what I've done: Copied across the ...
2
votes
2answers
2k views

Alter query on edit.php

What's the best way to alter the query being run on the Posts Edit screen (edit.php)? The current method I'm using is by passing an argument to the global $wp_query like so: $wp_query->query( ...
0
votes
1answer
2k views

Adding custom field values to wp_list_pages

I am trying to pull in a custom field vales for each page while using wp_list_pages. For example I want to list out each portfolio item in my sidebar but also show why type of work it is by pulling ...
0
votes
2answers
3k views

How can i show all categories using wp query?

<?php $recent = new WP_Query(); ?> <?php $recent->query('cat=1&showposts=2'); ?> With what can i replace cat=1 to show posts from all the categories?
-1
votes
1answer
174 views

Add content in between of foreach

I have the following foreach witch gets all the content in several groups. I am using Magic Fields. <?php $omtaleseksjoner = get_group('Seksjoner'); foreach($omtaleseksjoner as $seksjoner){ ...
0
votes
2answers
543 views

Custom Field Date Problem

I have a custom field called expiry_date with a value of let's say 2010-12-11 00:00:00. What I would like to do is, in my query loop, only return posts with this expiry_date custom field attached to ...
1
vote
3answers
500 views

Search and replace text across all posts

I had used the ZD Video Plugin for WP a long time, and now, since my move to WP 3.0.2, it doesn't work anymore. To embed a YouTube video using the plugin, I would just write ...
42
votes
5answers
70k views

How to display sql query that ran in query?

I have come across a function before that displayed the exact SQL code that was used in a loop for example, but can't remember. Can anybody tell me that function? Cheers
0
votes
2answers
263 views

What is wrong with my wp query, cant exclude the category that i want

query('showposts='.$display_count.'&orderby=comment_count&category__not_in=14'); It wont exclude the category that i want. Posts still show up
14
votes
4answers
17k views

Pagination not working with custom loop

I've got a custom loop that I'm using to display some Real Estate listings that will be available within 60 days. I'm calling it with the following function: <?php $sixtydays = date('Y/m/d', ...
2
votes
1answer
210 views

WP database error for comments_popup_link()

I'm using the comments_popup_link() function to show the number of comments for each post in a loop. <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php if ( ...
0
votes
2answers
1k views

Display posts separated by Category in Author's page

I created an author's page using: <?php if(isset($_GET['author_name'])) : $curauth = get_userdatabylogin($author_name); else : $curauth = get_userdata(intval($author)); endif; ?> ...
0
votes
1answer
679 views

SQL error with custom query

I'm trying to create a custom post query for sorting posts that have been voted "thumbs up". I'm joining my custom "wp_post_votes" table (which stores the number of votes each post received) with ...
0
votes
1answer
452 views

Placing a widget with $wpdb query

I'm getting the feeling that adding Widgets via MySQL query is not as simple as I thought. I was under the impression all data is stored in the options table, but it seems like I was wrong. Any idea ...
2
votes
1answer
354 views

mysql query paging

Hi I have made an sql query that gets several posts according the parameters that i've selected. I'm showing these posts but the inner paging within wordpress doesnt do anything. It shows me that ...
0
votes
1answer
2k views

Why can't I exclude private posts from this query?

My WP query to fetch some custom posts should exclude private posts, but this query is returning all posts, not just public ones: $wp_query = new WP_Query( ...
1
vote
1answer
3k views

SQL query to select posts from multiple categories

I have built a query to select posts within a category. Works fine. But when I choose to add a secondary filter to exclude a category, the query return the same result set, as if the secondary ...
0
votes
4answers
2k views

How to filter post from categories only if the posts appears in one of them, not the other?

The scenario is, some posts have one category, ok. Some others have more than one category. I must create post with content and also slideshow thumbnails for use with Nivo plugin gallery. Ok. I want ...
241
votes
7answers
86k views

When should you use WP_Query vs query_posts() vs get_posts()?

It seems like half the tutorials in the Codex and around the blogosphere use query_posts() and half use WP_Query. What's the deal?
0
votes
1answer
407 views

WP_Query older new links navigation?

I'm doing a custom query using WP_query to get posts from a specific category, but for some reason navigation links for the list don't appear. Is there a way to get the newer/older links to show up ...
14
votes
4answers
3k views

Show a different number of posts per page depending on context (e.g., homepage, search, archive)

In the Reading Settings, there is place to set the number of posts shown that affects the number of posts shown in all contexts. I'd like to show instead a certain number of posts on the homepage, and ...