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

learn more… | top users | synonyms

0
votes
1answer
8 views

wpsc: detect current sub-category [on hold]

I'm looking for a way to detect the current sub-category in use on the WP E-commerce plugin (http://getshopped.org). Detecting the current parent category is easy enough, thus if you use <?php ...
1
vote
1answer
10 views

Get IDs of posts currently visible on archive

This probably is a easy one for many. And also probably is already answered here, but I don't know how to search for it - so sorry I did search but not found anything. I like to get the contents of ...
1
vote
0answers
10 views

Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin

I have a wordpress table like so (phpmyadmin and MySQL) | id | meta_key | meta_value | +----+-----------+------------+ | 1 | import_id | abc | | 2 | import_id | abc | | 3 | ...
0
votes
2answers
39 views
+50

How to query categories with Advanced Custom Fields?

I'm currently using Advanced Custom Fields and I was wondering if anyone know how to filter categories by custom fields? I have a custom field in my categories using the checkboxes field. I want to ...
0
votes
0answers
21 views

Query by 2 values of a repeater ACF field

Let's say I have a custom post type called Film, with a repeater field called Showings, with fields start_datetime and discount. I need to make a query for those Films that have at least one showing ...
1
vote
1answer
33 views

Custom Post Type order by modified date and custom meta field issue

I'm creating a plugin with some kind of offers that users can publish. User, in his custom administration panel, can managed his own offers. Offers are free and premium. If offer is premium it take ...
1
vote
1answer
14 views

How to display posts by vote count and if no value continue with latest posts with no votes?

Maybe someone can help me with this. I want to display posts by votes. Users can only vote up. So what I want is - the most voted posts by vote count on top and then latest posts with no votes. The ...
0
votes
1answer
35 views

Custom Search Query

I'd like to set up a custom search page that does the following: User checks off several items in a form that he'd like to see returned in his search (essentially choosing from a list of tags). ...
1
vote
2answers
36 views

Different Ways to Query Custom Post Types?

I'm using this code to use custom post types like regular post: add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); function add_my_post_types_to_query( $query ) { if ( is_home() && ...
1
vote
1answer
28 views

Query custom post type only if it contains another custom post type

I currently have a custom post type named "blog". On registration, every user gets automatically a post "blog" linked with their user ID. This custom post type queries another post type named ...
-1
votes
0answers
24 views

Woocommerce conflict with pre_get_posts

I implement woocommerce in my theme but I have a conflict with my custom query that I added for my archive template. I can't figure out how to make work pre_get_posts with woocommerce activated. ...
1
vote
1answer
25 views

Custom query AFTER rss fetch_feed not working

I'm trying to do a custom query after an rss fetch_feed but for some reason nothing shows up. The code I'm using to fetch the feed is: <?php // Get RSS Feed(s) include_once( ABSPATH . WPINC ...
0
votes
1answer
28 views

Order terms by count - missing terms

I have this problem: I'm using get_terms with ordering by count. And some terms are missing - I have no idea why, there is no exlude, or hide posts or anything like this. What is wrong? Here is the ...
0
votes
0answers
17 views

include taxonomy terms in search query

I currently have a search query set up that only displays the post_type of listings in the search results, I want to amend this query to include a custom taxonomy also. I have a custom taxonomy for ...
0
votes
0answers
41 views

There is way to improve this query? wordpress get post data and some meta data

Suppose we have 2 blog with different database A and B. I want to get some post from Blog B to show them on Blog A. The problem comes when the posts have much metadata (custom field for example) that ...
0
votes
1answer
36 views

SQL to update custom post taxonomies

I have a custom post "review". It uses the same categories and tags from default posts, so they share "category" and "tag" taxonomies. But later I changed the "review" register to have their own ...
0
votes
0answers
26 views

Echo post content from archive page

I am trying to pull the latest post content in a archive page into the meta description, this is what I got: <?php } elseif (is_tax()) { ?> <meta name="description" content="<?php ...
1
vote
1answer
45 views

Query posts by content lenght

I am using the code below to pull a random post of my site every 6 hour. if ( false === ( $social_trans_post_id = get_transient( '$social_trans_post_id' ) ) ) { $args = ...
1
vote
1answer
36 views

Pagination with $_POST and $_SESSION

I have a page on my site where in the left column is a set of checkboxes representing taxonomies and in the right column is a list of posts that fall into the selected taxonomies. The user is able to ...
0
votes
0answers
16 views

Multiple Taxonomies Using Custom SQL Query

I am running a custom SQL query, and I am trying to pull posts with two taxonomies assigned to it. Here is my query which works: $querystr3 = "SELECT *, events_startdate.meta_value AS ...
0
votes
0answers
21 views

Using taxonomies to filter content

I have a wordpress install with ALOT of pages. These all have specific terms, from a custom taxonomy attached to them. Is it possible to have a <form> send a query with multiple terms ...
0
votes
0answers
28 views

Run query once inside a loop

I am trying to prevent to much queries inside a plugin one of my plugins. I have a query inside a function which will output a complete block with some layout elements and an input element which will ...
1
vote
0answers
71 views

How to get latest posts from each category in regular order

let's say I have a main query and it displays posts from Movies and Music categories. I want the query to show always 5 latest posts from Movies and 5 latest posts from Music category. When I create a ...
1
vote
1answer
36 views

Change media attachment author via mysql query

How does one bulk change the media attachment author via an sql query? I have hundreds of media attachments that need to be moved to another author so the original author can be deleted; but that ...
2
votes
2answers
78 views

Automatically adding meta data to posts or multiple query help

I run an events company whose website uses a custom post type system for posts (blog), events and tickets all stored as CPT's in the DB. On the guestlist (which counts 'ticket' custom posts if the ...
0
votes
2answers
38 views

Query to view scheduled or draft post

I have created a mailer template for my my single post. I can view the mailer version of my post using a url variable ?mailer I've configured the above using the code below within my single.php... ...
0
votes
1answer
21 views

Declaring a var, placing it in a query and using the output of the query?

So i'm wondering if it's possible to declare a variable that you'd place in a query to then use it in a update_post_meta function? This is how I tried to do it. First off I made a connection to ...
0
votes
0answers
31 views

wordpress page filter problems

Hello I been working on post type filter so I can filter my content for taxonomies type but for what ever reason I can never get it to filter when I click filter public function product_filters( ...
1
vote
1answer
24 views

Rewrite Rules returning wrong data

I have a custom post type called product. It is categorized with the two taxonomies product_category (which is superior) and product_group. I want the permalinks for single products to appear like: ...
0
votes
0answers
19 views

Best way to execute custom page-specific mysql queries

I would like to query a secondary mysql database (not the Wordpress mysql database) with page-specific queries. I've seen many answers / tutorials on setting up a secondary mysql database, like: ...
0
votes
2answers
53 views

Inserting data into `post meta` table?

How would I be able to insert data into the post meta table? I know how querying and wpdb works but I have no idea how I can just insert it into the table. I have these two fields I want to insert ID ...
0
votes
1answer
23 views

About WP's save_post action

Quick question, in API's some times save_post is used(most of the time actually). Is save_post the equivalent of the query action INSERT INTO whereas save_post saves metadata and forces Wordpress to ...
0
votes
1answer
55 views

Query posts from a specific category and selected tag

I am trying to have a page (tag page) with this conditions: query posts from a specific category (for example : products) show only the posts with a selected tag (the tag is variable) not all the ...
0
votes
1answer
24 views

How to SQL query posts IDs by categories AND authors?

I am making a custom WP_Query and I need to come up with a SQL query that gets the posts IDs from X categories and Y authors. Then merge those IDs and put them in an array. I only need to figure out ...
0
votes
2answers
53 views

Wordpress and a secondary database?

I have to achieve something on which I don't know how to approach it. Base of the issue: There's a bunch of data in another DB that I have to import into WP which so far wasn't possible due to them ...
0
votes
1answer
21 views

Custom types, taxonomies and query optimization

I'm doing a re-design and re-coding of a fairly large Wordpress website. As part of it we're adding some different post types representing various data types (website will have additional data-driven ...
0
votes
2answers
19 views

Include both default and Custom Post Type in query modified inside pre_get_posts

I want to include custom post type in the author arhive page. I tried the method discussed in this post: Including post_type = 'wiki' in author archives add_action( 'pre_get_posts', ...
2
votes
1answer
59 views

Custom Post order for homepage

I would like to display a dropdown on the homepage which contains [most popular, most recent, trending] and when a user selects on of them the posts are page reloads and the posts are sorted in that ...
0
votes
1answer
28 views

Minimize database queries to user tables?

I'm trying to come up with a strategic way to collect large amounts of usermeta data (and output to the screen) while keeping database queries low. Some pages, like the home page, single pages, and ...
0
votes
1answer
21 views

Connecting to a 2nd DB gives me no results when querying

I'm trying to access a different DB on the same localhost as my wp db is and I did this like so: functions.php: add_action('init','my_new_db'); function my_new_db(){ $newdb = new wpdb( 'test', ...
1
vote
0answers
22 views

Order posts with a custom field but also without

I am querying and ordering posts with this code but my theme adds the custom field (cb_vote_nb_vote) only if someone clicks the "vote" button, since I am doing a listing, posts created without that ...
-1
votes
1answer
8 views

The page that displays Posts on homepage

I want to know the page responsible for displaying the blog posts in WordPress. Where I can probably expect to find the SQL query and post rendering so I can edit some stuff by myself.
1
vote
1answer
82 views

Advanced Custom Fields - Query Efficiency

For testing purposes I have edited page.php to have nothing other than: <?php while ( have_posts() ) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php $site_options = ...
0
votes
1answer
23 views

Continuous listing from a custom field

I have posts with custom fields called "cb_vote_nb_vote" which holds the vote count for every post, what I want to do is let's say posts under A category will be listed based on vote count, I do that ...
0
votes
0answers
31 views

Working with arrays/foreach statements - echo results? Addition operator w/foreach… multiplying?

I'm really struggling with this - I'm relatively new to PHP but I'm trying make this code that I've pulled together output a list of chapters sorted by user pageviews based on a user_meta field called ...
0
votes
2answers
35 views

Undefined variable: row?

I'm trying to select the post_title from wp_posts with a query which I did using this method: global $wpdb; $test = $wpdb->get_var( $wpdb->prepare(" SELECT post_title FROM ...
0
votes
0answers
44 views

MySql Query very slow

I have a problem with a query on my website. When I load the page it is incredibly slow and only after over 12 seconds the content starts showing. I have installed a debug plugin and found the query ...
0
votes
0answers
19 views

Proper way to trigger a MySQL query via link in a plugin

I am trying to develop a module in my WordPress plugin that will delete an entry from the database. The only issue is related to the trigger action. I've tried to send my users directly to the page ...
0
votes
1answer
43 views

WP MS: How to query over the network

I have a WP 3.8.1 Multisite installation with 3 blogs, they're all in one db, prefixed wp_, wp_2_ and wp_3_. In a template in wp_ I try to to display all posts from wp_, wp_2_ and wp_3_ which have a ...
1
vote
3answers
63 views

How to echo excerpts with wp_list_pages?

I've tried to echo excerpts in wp_list_pages with the code below. It works, but only for one of the child pages. How would I echo the excerpt and title for each child page? <?php $children = ...