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

learn more… | top users | synonyms

1
vote
1answer
46 views

Displaying Posts from Custom Post Types

I'm trying to display posts from regular and custom post types : <ul class="scroll"> <?php // the query $the_query = new WP_Query( 'cat=-4,-142,-143,-144' ); ?> <?php ...
1
vote
0answers
39 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 | ...
1
vote
0answers
226 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
44 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 ...
1
vote
2answers
52 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
62 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 ...
1
vote
0answers
217 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
44 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: ...
1
vote
0answers
24 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
vote
1answer
30 views

How can I setup a relationship using categories in WordPress?

I am trying to setup a relationship between a "People" post type and a "Work" post type. For example, I want to have a structure like this Person 1 - Work - Work 1 - Work 2 Person 2 - Work ...
1
vote
2answers
174 views

Get comment content by comment ID

So I've been trying for a hour or so now to list comment by it's ID. I've tried the get_comment($id, $output) function but it didn't work well, so I went back to whatever is shown below, but it just ...
1
vote
1answer
80 views

Query Wordpress database by registered date and role

I would like to get the display name and email address for all users who have registered to my multisite today with the role of subscriber. It needs to be an SQL query as it's used outside of the WP ...
1
vote
1answer
305 views

How to reduce the number of queries?

I have meta key "Due" for posts....if a post has expired (past the current date or not equal to it) then it will not be displayed in the count. This is my code, which works perfectly. My only problem ...
1
vote
0answers
48 views

wordpress query - orderby child post date

I have support ticket system which i have built using wordpress. The basic functionality is that when a "ticket" is created, it creates a post. When an admin replies, it then add a child post to the ...
1
vote
2answers
54 views

Exclude the first 'n' number of posts of a tag from home page?

Use case (example): Using a separate, custom query my website's home page shows 5 featured posts, tagged 'Highlights (highlights)', followed by the latest posts, from the main query. I don't want the ...
1
vote
2answers
288 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', ...
1
vote
1answer
175 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 ...
1
vote
1answer
94 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 ...
1
vote
0answers
72 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 ...
1
vote
0answers
84 views

Post 2 Post Site Search

I'm trying to filter search terms bases on categorisation created by posts 2 posts. I'm using the generic site search and then I've created a search filter function my_filter_the_search($query){ ...
1
vote
0answers
42 views

Wordpress Query orderby title with UTF8 string in title

I got posts with titles are in utf8 encoding. When I query posts with orderby is title, those with utf8 characters at the beginning are at the end. Example: post title starts with Đ are at the end ...
1
vote
0answers
47 views

Sorting main query by custom taxonomy slug

Is there a way to sort posts by custom taxonomy (shoe_color) ASC|DESC? I would like to do this using query_posts and passing the orderby=shoe_color into it. Here is the code I'm trying to work out: ...
1
vote
1answer
119 views

Searching With Apostrophe

I'm having trouble with my custom theme's search function. I have a number of posts with apostrophes in the title. For example, McDonald's. However, when I try searching say McDonalds, the post won't ...
1
vote
2answers
775 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 ...
1
vote
1answer
121 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
217 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" ...
1
vote
2answers
153 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
67 views

Wordpress Custom post query sorting does not work

I created a custom WP query to collect products that have 3 different taxonomy values in them and sorted them by price using the following: $my_products = new WP_Query( array( ...
1
vote
0answers
117 views

Changing status of Published posts which have less Content to “Draft”

function draftpost(){ global $wpdb; $prefix = $wpdb->prefix; $wpdb->query("UPDATE ".$prefix."posts SET post_status='draft' WHERE LENGTH( post_content ) <500"); } ...
1
vote
0answers
290 views

WordPress Query wp-terms SLOW

I've got a very large database in WordPress with lots of products in WooCommerce along with quite a bit of taxonomies. When querying the products on the front end it takes 1 minute or more. Here is ...
1
vote
1answer
431 views

Trying to reorder posts by custom field

I'm running WooCommerce and am trying to get the default product display to be sorted by the sku field in ascending order. So far I've come up with this: /* Order products by SKU */ function ...
1
vote
1answer
142 views

Query posts from different categories in multisite

In my planed multisite installation, I want the members to be able to post in one of two different categories. Members in A can post in 1. Members from B can post in 2. All members can comment ...
1
vote
1answer
188 views

Is there a reason why Pages are not publicly_queryable?

I am building a segmented search (by post type) with the ability to filter to a specific post type and realized pages were not publicly queryable. What I know I can do is the following: function ...
1
vote
0answers
67 views

register_taxonomy() take much queries

Sorry for my poor English, I'm russian. I have a problem by adding a lot of taxonomies. When I added about 80 taxonomies, I get the following results(without caching): before: 44 queries 0.352 ...
1
vote
1answer
809 views

mysql query from wordpress page using custom table

I want to a mysql query that matches a page title. Not sure of a better way to accomplish this task, but I am stuck. This is my basic test code. <?php $page_title = wp_title(''); echo ...
1
vote
1answer
78 views

Limits, not all post are showen when querying for posts by view count

I'm having some difficulty getting a loop that gives me post by most viewed. I started by following this tutorial ...
1
vote
1answer
131 views

Query Page Content From Theme Options?

I'm trying to create a slider where you choose what pages are shown in the slider, using a theme options panel based on the https://github.com/vauvarin/options-framework-theme That lists the pages in ...
1
vote
1answer
145 views

posts_per_page option limits the number of Gallery items

I have noticed that if I have a query where posts_per_page are set to 4, any (image) gallery that belongs to one of those posts will too have only 4 items (although when I create the gallery from Add ...
1
vote
0answers
71 views

Why orderbyb meta_value_num won't affect the generated SQL Query order?

I've exhausted myself with this and I couldn't figure out why when I do this $myposts = new WP_Query( array('numberposts' => 5, 'offset' => '0', 'post_type' => 'noticias', 'orderby' => ...
1
vote
2answers
98 views

How to organise this data within WordPress

I have a dilemma in how the data in this scenario should be organised, as well as queried. The main elements in the scenario are the following: Competition Team Player Each player plays for one ...
1
vote
0answers
66 views

Dynamically adjust single-posttype.php query, based on current taxonomies

I have a single-teamphoto.php template loading data from a Team Photo - Custom Post Type, showing team photos with team member names below, one photo at a time, with a navigation list of available ...
1
vote
0answers
86 views

category pagination got broken suddenly

i need some help here please! The pagination just stopped working suddenly with the default post type and default wp query, with plugin "wp-paginate" or even with next/prev arrows! It echo 404 error ...
1
vote
0answers
289 views

Exclude posts with taxonomy term from appearing on home page query

I am really confused about this one, I am usually pretty good at working out basic queries but I can't seem to work this one out. Please see below my index.php query. Now it is not your basic query ...
1
vote
1answer
370 views

How to retrieve attachments from child pages of a specific Page?

How would I retrieve attachments from all subpages of a specific Page ID? Example: SPECIFIC PAGE Child (with attachments) Child (with attachments) Child (with attachments) I'm currently ...
1
vote
2answers
186 views

Query last updated posts (posts updated in the last 24 hours)

I'm having some difficulty to find an example of how to create a loop with posts that had been updated in the last 24 hours. My idea is to have a page of posts or perhaps on the index.php a lists of ...
1
vote
2answers
742 views

Search queries don't seem to work?

I have a problem with search queries. Anytime you put additional queries, like: mywebsite.com/?s=wordpress&post_type=page mywebsite.com/?s=wordpress&post_type=page,post ...
1
vote
2answers
60 views

plugin code is pulling information from database in one instance and not in other. What is wrong?

In my plugin code, I am pulling the table id from two tables. The id is being pulled from one table but not from the other and I get errors in both instances. The queries work on mysql when I use ...
1
vote
1answer
832 views

Query get post,how to add comment box

Hello I have a query that gets a post with id=x and it works but it leaves out the comment box. Is there a way to add "get comment box" to the query? <?php $post_id = 104; $queried_post = ...
1
vote
1answer
158 views

Query the post which have a thumbnail

I've got a highlight section on the header of my website which shows the title and the thumbnail of the last X posts having a thumbnail. Is there any custom query which allows me to retrieve only the ...
1
vote
3answers
356 views

I want to create a filter for the query string is this possible?

I have spent the last few days working on and researching this question and have found no solution. Basically I want to replace the query string which wordpress parses in order to query the ...