Questions tagged [query]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
11 views

add_post_meta - datas remains stored in the database [closed]

I use Formidable Form plugin. I need to get last name and first name author from single page to display these datas in form with Formidable Form plugin. To display these datas in my form I can use the ...
0
votes
0answers
13 views

How to do WP_User_Query for Nested Array value Inside Nested Array field

i am still new in wordpress development and try to playing with WP_User_Query right now. I have meta field, with this value: array ( 0 => array ( 'address' => array ( '...
0
votes
0answers
16 views

Get posts that are parents which don't have any children with WP_Query

I have a hierarchical custom post type which has posts with no children and also posts that have one or multiple direct children (only up to a depth of 1, i.e no children of children). For example: ...
0
votes
2answers
31 views

$post->ID not working in combination with a custom query

What is the reason that $post->ID is not working in metabox_callback after adding a custom query. How can I avoid this? Should I use $post_id = isset( $_GET['post'] ) ? $_GET['post'] : ( isset( $...
2
votes
2answers
535 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 "...
0
votes
1answer
596 views

how to insert missing tags into the posts through mySQL?

I am looking for a SQL query to insert a tag to multiple posts from a specific category. A pseudo query looks something like this: INSERT INTO POSTS VALUES TAG = "tagName" where Posts in_category("...
2
votes
1answer
536 views

Show All Posts Insert Edit Link

When I click to insert/edit link in the tinyMCE rich editor for a post, then click "Or link to existing content", it shows only posts that are live and published. Is there a way to get the list that ...
0
votes
2answers
643 views

Get first comment link on the post itself

I have this function and a link to a post: <?php foreach ($results as $id) { $post = &get_post( $id->ID ); setup_postdata($post); <li><a <?php href="<?php ...
0
votes
1answer
677 views

Divide WP_Query posts by date & post type

I have a WP_Query that divides 2 Posts types by date but the functionality is not there. Currently it outputs the dates and posts on the same level like.. -Date -Post -Post -Date -Post -Post What I ...
1
vote
0answers
20 views

Iterating through $wpdb query without using get_results for large query results

Traditionally, whenever I've needed a real mysqli_fetch for things like importing thousands of rows of data, I've used my own database connection and framework. But I was thinking there must be a way ...
0
votes
0answers
16 views

query_posts in pre_get_posts removes all body classes - how can I reset or keep them?

I've created a function that searches images for a tag, uses them to create a loop and build an array of their parents' IDs. Its in a pre_get_posts. Its all working fine except I'm obviously ...
0
votes
1answer
2k views

Count posts for pagination

I'm doing the pagination for a web. < Previous (pagenumber) Next > is easy, already done. But now I need to add a selector to go to a page directly (ex: to page 7), to do so, I need to know how ...
1
vote
0answers
14 views

Modify the query method when adding category filtering function to the custom post list

The following code, which I found in the forum, adds a category filtering function to the custom post list. This code can correctly filter the single-select taxonomy. My custom post type, in actual ...
0
votes
2answers
22 views

How to explode single string IF it's used in shortcode

I have a shortcode that works to display posts from specific categories, or a single post based on the post slug. I'm having trouble figuring out how to get it to display multiple posts based on their ...
0
votes
1answer
629 views

Problem on wpdb queries, wp_insert_post, wp_insert_user etc. The query runs twice

Anyone encountered this issue? I have created a custom php script which adds a new post by using wp_insert_post() but everytime I run the code it creates a 2 new post where in it should be only be ...
0
votes
2answers
779 views

Conditional posts in WP_query for search

I have a custom post type that im trying to limit results in search. The CPT is a deal/coupon, with a start and end date for each of the deals. What I'm trying to do is only show these posts in ...
0
votes
1answer
5k 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 get_calendar()...
0
votes
1answer
2k views

How to do a MySql query in WordPress?

I want to get the last auto-incremented ID's value of a particular table. I found a MySql function on the internet to do that. But I'm not sure how can I use this function in WordPress to get the ...
0
votes
1answer
846 views

How to get all images in Media Gallery with pagination?

I want to get all images in the image gallery with pagination so that I can use infinite-scroll with it. The infinite scroll works but it's taking the posts' number of post, not the images. That ...
26
votes
5answers
150k views

How to limit the number of posts that WP_Query gets?

I have been researching on Google and WPSE and the only thing I see repeatedly is to use showposts, that is deprecated. I am familiar with WP_Query, and I thought that if I set posts_per_page to my ...
4
votes
1answer
668 views

WP_Site_Query vs. WP_Network_Query in WordPress 4.6

Can someone explain the difference between WP_Site_Query and WP_Network_Query in WordPress 4.6? WP_Network_Query() : Core class used for querying networks. WP_Site_Query() : Core class used for ...
0
votes
0answers
16 views

Pass query params between pages

I have a link which I send to customer email with some seo params. https://wordpress-example.com/?test=123 but after go to another page I missed it. How to deal with it and pass this parameters ...
0
votes
1answer
27 views

WP_Query filter by custom meta

I try to make a page to list users with a meta values. I search to get all users with a site url or user_description Thx
1
vote
1answer
656 views

I am trying to hide a custom post type category to logged in users with Pre_Get_Posts

I have a custom post type in my theme called portfolio. It's categories are called project-categories. I am trying to exclude a project category for logged in users. I cannot get this to work at all. ...
0
votes
3answers
851 views

Set SQL_BIG_SELECTS and MAX_JOIN_SIZE on a WP_Query

Despite using; $mysqli = new mysqli("localhost", "user", "pass", "db"); $mysqli->query('SET SQL_BIG_SELECTS = 1'); $mysqli->query('SET MAX_JOIN_SIZE = 999'); $the_query = new WP_Query( $args )...
1
vote
2answers
615 views

Creating a custom search for a specific post type

Ok, so we know Wordpress comes with a built in search form. However, I've created a custom archive page that lists posts from a specific post type. I would like to integrate a search box that only ...
2
votes
1answer
2k views

Display related products with custom output

I'm trying to display the related products with my custom html output, unfortunately i'm kind of lost on how to do this. The WP_Query below displays the products that are in stock, what i want is to ...
0
votes
1answer
13 views

Get posts from category with custom query

I've got a custom sql query to get latest posts from specific category (ID = 62). It looks like this: SELECT p.ID, u.display_name AS author, post_date_gmt, post_title, p....
0
votes
1answer
15 views

How to get inserted row IDs for bulk/batch insert with wpdb query?

I'm writing a plugin where I need to save data in custom tables, function hits an API and then saves data for which I need bulk insert, but as wpdb doesn't support it out of the box I made a function ...
1
vote
1answer
11 views

Replace/Mute/Stop Search Query

I'm trying to replace the search functionality in WP. I've already created the search.php template with all the results I want to display. I don't want any results from the WP database. I just want ...
0
votes
0answers
18 views

Custom WP search not looking at page tags

So, i created a custom search using WP_Query and it is working as i need it to except for the fact that it does not seem to be searching in page tags (i have a custom plugin that allows me to add tags ...
0
votes
1answer
15 views

Why Query is returning empty array?

I am trying to execute a query using the below code but I'm getting empty array in var_dump. global $wpdb; global $post; $slug = $post->post_name; $course = $wpdb->get_results( "SELECT * FROM ...
0
votes
0answers
12 views

WP_Query orderby meta_value Speed

I currently sorting my posts using this code: function main_query($query) { if ( is_search() || is_home() || is_front_page() || is_archive() ) { if (!is_admin() && $query->...
0
votes
1answer
846 views

Query Pulling the same post twice

After seeking help and failing, I managed to write a query for Wordpress that does exactly what it's suppose to do, however it pulls the post that it's suppose to in twice. I've stared and stared at ...
0
votes
1answer
739 views

Pagination is not working on custom query inside a custom home page template

I know this is a duplicate question. But to comment on existing question, I dont have enough points. So here we go.... Pagination is not working on custom query inside a custom home page template. ...
0
votes
1answer
31 views

Echo multiple tasks if a common function exists

How can I echo multiple tasks if a common WordPress function exists. For example, I want to reduce the following: <?php if (function_exists ('pluginName')) echo someName (1); ?> <?php if (...
0
votes
1answer
1k views

WP Query - Search in title or author_name

My need is to have a WPQuery that searches for posts which title is 'test' OR author_name is 'test'. Here is the code I tried: $search_query = get_search_query(); $args = array( 'relation' =>...
0
votes
1answer
1k views

Creating a Back button on detail post page to go back to blog page with same query strings and page id

So, I would like to have a back button on the single post page that can be dynamic to the point to where it knows where it is in the query and bring me back to the blog page on the right page number ...
2
votes
4answers
7k views

How to count get_users query?

I have been searching high and low for a way to count the amount of results from a get_users query. Most of what I found is to count the total number of posts in a post query, but nothing for ...
0
votes
1answer
28 views

Delete oldest wordpress post (SQL query)

I've reached the database limit on my hosting platform. I want to add a function to my functions.php that deletes the oldest post in my database anytime that I publish a new post. function ...
0
votes
1answer
783 views

Merge two queries and remove duplicate

I want to merge two queries together and remove duplicate. I got it working individually. Now I got it working together but the results are not mixed and the duplicates are not removed. So I got the ...
0
votes
0answers
123 views

Display posts from today and future in Elementor 'posts widget'

According to Elementor documentation https://developers.elementor.com/custom-query-filter/#Multiple_Post_Types_in_Posts_Widget I need to display future posts including the post from today. We want to ...
0
votes
3answers
2k views

Performance bug - slow DB query

Since 2017-09-26 I have terrible problems with performance on my website. Loading single post or any other page takes even 20s. I've been debugging it it found out, that the problems are DB queries. ...
1
vote
3answers
2k 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): I'...
0
votes
2answers
1k views

Query String for the WP_QUERY parameters

I don't know how to turn some WP QUERY parameters into url query strings. Most of them are straight forward, but there are some I don't know how to get working. For example, for these WP_QUERY ...
0
votes
3answers
2k views

Find woocommerce product ID by custom field value?

I try to find a way to get products ID by custom field in a category. I use this: // Get the category $catsearched = $atts['category_id']; // Get all product of categoryselected $product_args = ...
0
votes
1answer
29 views

Strange string in console from wpdb query

I use this code: $search = $this->wpdb->prepare("WHERE (name LIKE %s OR tag LIKE %s)", '%'. $this->wpdb->esc_like($word) .'%', '%'. $this->wpdb->esc_like($word) .'%'); and in ...
0
votes
0answers
16 views

Show post only for user that matches category

Disclaimer: I am not a developer. I know really a little code. Hey! Thank you for your time! Well, the situation is like this: I have posts that are set to "CategoryA" for example. In Elementor I ...
0
votes
1answer
788 views

Using wp_list_table how to trigger update function “inline”?

Ok, i have used wp_list_table to read data from a custom db table and i like to be able to update the database table by clicking the correspondig cell. Defaults are 0 and when clicked the value is set ...
0
votes
0answers
7 views

Thickbox to display the result of a custom db query in admin

Is it possible to add php generated output in a Wordpress thickbox? I have the thickbox working fine from a button in a custom meta box, it displays html without issue. However, what I actually want ...

1
2 3 4 5
35