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

learn more… | top users | synonyms

0
votes
1answer
25 views

How to fix this insert? Don't work for me!

I need to fix errors of this insert because this don't work in my script. I'm a beginner in WordPress SQL. Thanks $wpdb->insert('wp_cadastrados', array ( 'ID' => NULL, ...
0
votes
1answer
464 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
0answers
27 views

Querying on a custom post type without tags returns no posts

A theme I'm working on contains a custom post type, "help_question", which is declared as such in functions.php add_action( 'init', 'create_post_type' ); function create_post_type() { ...
0
votes
1answer
484 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
7 views

Query if audio attachment AND/OR custom field

I've been trying several things but to no avail... Searched, maybe not good enough though! I have posts that either have an uploaded audio file AND/OR has a Soundcloud link (which is a custom field). ...
2
votes
1answer
376 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 ...
0
votes
1answer
19 views

How to add div blocks after certain set of post

Ok I broke my post down into different style settings. Like shown below. The first post is a large block. the next four post are small and aligned next to the larger post. I used the loop below to ...
0
votes
1answer
23 views

Inner join overrides Advanced Custom Fields plugin's get_field

I have this search that I made with inner join and where clause. I no longer get get_field() values, they all return false. How can I get ACF to work again? It must be something silly that I don't ...
0
votes
0answers
14 views

Add generic page to WP_Query

I have a query that gets all my custom post types of Service. I need to add a generic page (Classes) to the query so that I can use the orderby argument. I know the ID of the page I need to add. How ...
0
votes
1answer
375 views

Query set using tax_query with relation 'OR' modifies category object?

(Update: Please see the edits far below.) The code: function itsme_better_editions( $query ) { if ( $query->is_category() && $query->is_main_query() ) { $query->set( ...
0
votes
0answers
9 views

MySQL query in Functions.php using inner join to override/add to search

I'm setting up a radial geo-location search. I have users select a zipcode and a radius to search within. I want to use the regular search site.com?/s=abcd&zipcode=90210&radius=10 I look up ...
-1
votes
0answers
8 views

Query custom post type by taxonomy without running the whole custom post type

This query that I have show all the posts that I have in my books custom post type: <?php query_posts('post_type=books&showposts=-1&order=DESC');?> <?php while (have_posts()) : ...
0
votes
2answers
522 views

How to exclude custom fields from search queries?

I'm building a hotel search engine and I've first created a custom content type "hotel" with Types & Views Toolset. I'm using "Search everything" plugin to query custom fields and custom taxonomy ...
0
votes
1answer
24 views

Hide text if query has no posts

I'm using a custom query to display events CPT inside another CPT. The given query has a section title, which I don't know how to hide when there are no events. I've tryed to include the section ...
0
votes
2answers
34 views

Problem in exploding the_content to array

I've written a code in a WP_Query to converting a string (the_content) to an array (choices). But it seems wrong! In fact, the choices array is empty after each loop. However str string is notnull. ...
0
votes
1answer
20 views

Create custom query for search?

I have create search box using ajax.If i enter any value in search input box that this value search in post title or post meta data and get all data of this value in custom post type.also query check ...
0
votes
2answers
642 views

Custom MySQL Query for Post and Post Meta

I have a custom table called "tags" that contains a charity_id that is a reference to a post ID ... I need to query the "tags" table to grab this charity_id and then pull in the post title and a few ...
0
votes
2answers
194 views

The use of including upgrade.php when building custom queries

I started building a plugin in which I need to build some custom queries with wpdb object. It's the first time I use it. So I checked out how to use it. I watched some examples and there is something ...
0
votes
1answer
18 views

Empty tax_query array returns an empty array

I would like to return all posts when the tax_query['terms'] is empty. $args = array( 'post_type' => 'product', 'posts_per_page' => 15, 'paged' => $paged, ...
1
vote
1answer
455 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 ...
0
votes
1answer
348 views

Delete Query won't run

This is the set up... <form method="post" action=""> <input type="hidden" name="delete_app_id" id="delete_app_id" value='<?php echo $adoptee->app_id; ?>' /> <input ...
10
votes
8answers
50k 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 ...
0
votes
1answer
37 views

Get the post permalink within the loop but without additional DB query

I am looking to create a custom 'directory' page which will link to several thousands of posts. Because of the large number I am trying to limit the number of DB queries. I notice that to link to each ...
2
votes
2answers
2k views

Get category slug and display it on a query_post

I just read "How to create option page for wordpress theme" in wp.tutsplus.com - I have a problem with getting categories . there is two parts to my question - Part A - Get category slug and ...
0
votes
1answer
20 views

Advanced Custom Fields Query with Different Values of the Same Key

I have a custom post type set up with Advanced Custom Fields. I would like to display and order my posts in groups. The groups are states of the United States, so I have 50 groups. Should I perform ...
0
votes
2answers
20 views

Where and when does WordPress invoke routes

One of my URLs for which I'm wanting to create a Category Archive is coming up with a 404 despite having matching routes and, supposedly, matching templates. I'm going through the core WordPress code ...
0
votes
0answers
8 views

No results for taxonomy archive page

So, I'm making a taxonomy template page for a plugin, but I'm not getting any results from my query. I'm loading the template with this. function projects_categories( $taxonomy_template ) { if( ...
0
votes
3answers
1k 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
57 views

How to show posts rank based on custom field value

I have total 100 posts, 10 posts in each page on homepage with paginatin. Here is my code $args = [ 'posts_per_page' => 100, 'fields' => 'ids', // Add additional args here ]; ...
0
votes
1answer
476 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
votes
0answers
10 views

Genesis and Woocommerce Products Per Page [on hold]

I’ve been searching for an answer for this for a while and am stumped. Any ideas are greatly appreciated. I’m building a custom child theme on the Genesis framework, and am stuck on the WooCommerce ...
0
votes
1answer
17 views

meta_value timestamp older than now

In my wp_posts table I want to select the rows where post_type == event. I also want to a connection with wp_postmeta from the specific row. In my wp_postmeta table I want to do a where like this: ...
1
vote
3answers
72 views

Limit number of pages in pagination

I have more then 500 posts and I want to limit only 100 posts with pagination. So, 10 pages with 10 posts in each. Here is my code. $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; ...
0
votes
0answers
12 views

WP Query for newest post of each taxonomie of a custom post type

I'm trying and googleing since 2 days, but cant figure out how I can display my 8 needed posts. Details about my structure: I'v created an custom post type "projects" where all the posts about ...
6
votes
4answers
33k views

Proper way to get page content

I have to get specific page content (like page(12)) I used that : <?php $id=47; $post = get_page($id); echo $post->post_content; ?> Work nice execpt for compatibility with qtranslate ...
1
vote
1answer
130 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
0answers
10 views

Get adjacent post data, ordering by custom field values (by Wp-query?)

I want to build a custom version of the adjacent-function of wordpress post. I have two custom field values for each post, my layout is the following: metafield1 value 1 & metafield2 value 1 | ...
0
votes
0answers
16 views

Add a banner image after first post, across the WordPress website [duplicate]

I am looking for a way to add a banner image after first post across the website. If it was about adding a banner on one page only, homepage or category page, then I could have done this in WordPress ...
1
vote
2answers
559 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
3answers
2k views

Sort posts by category name and title

Trying to figure out how I can output my posts based on category title (a–z) and secondly, the title of the posts within the category: A CATEGORY – A post beginning with a – Because I want to be ...
0
votes
0answers
10 views

How can I take input from a form, run it through a custom query, and display the results?

I'm having a good bit of trouble here. I'm working on a plugin that should be able to, among other things, allow the use of a shortcode to search through custom post types and their custom fields. I ...
0
votes
1answer
56 views

Ascending & descending posts on same page with IF statement

I need to be able to display a list of events on 1 page. The top list would be for upcoming events and to be sorted with earliest event first and the second list would be for expired/past events and ...
0
votes
0answers
16 views

Problems with database query where two metavalue-key pairs meet condition

I've been trying to put together a database query where the different meta_values of two different meta_keys match the query. One example would be: delivery_date is '2015/06/11' AND supplier is ...
1
vote
2answers
34 views

WP Query. Is there a maximum size?

I develop a plugin that searches for a duplicates of WooCommerce products in a very specific way. It works great in our test environment, but on the client's original setup it does not execute. It ...
0
votes
0answers
22 views

Add custom field to string URL query

I recently took over a wordpress site from a former employee and I have 0 experience with this CMS aside from creating child themes. That being said, I'm trying to allow my search page to list out all ...
0
votes
2answers
394 views

Get ID of child from child slug, while knowing parent ID

I have a hierarchy that I need to get data from. It's the child (by slug name) that I need to get while already having knowledge of the parents. Highest Known Parent Page (slug : 'parent') |_ Child 1 ...
1
vote
0answers
40 views

How to query all posts of a specific category, and any other category combination

Basically, I'm looking to query all post of category 'news', and any combination of other categories to display as Related News on single content type pages. So, if someone writes a post, and ...
0
votes
1answer
26 views

Is it possible to query the result of a query?

I'm not sure if the is even possible, and couldn't find an answer, so I figured I'd ask on here. Basically I want to know if it is possible to query a query result? What I want to do is query for ...
2
votes
1answer
2k views

order by numeric value for meta value

I have read countless posts on ordering data by numeric value ( as opposed to string - it i have a numeric meta value and it gets ordered like this 1 11 12 2 233 etc as opposed to the way i want it I ...
1
vote
1answer
531 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 ...