Tagged Questions

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

learn more… | top users | synonyms

0
votes
2answers
173 views

mySQL queries are executed twice on wordpress website

I'm sorry for my english. I'm trying to add some functionalities at my Wordpress website and to do this i have added a function in my function.php theme. The idea is to save in a custom table some ...
0
votes
1answer
30 views

How do I get all results from my query

I have written some php code and using the class.pagination.php, am able to paginate it based on a max posts per page that I set inside my code. This works great. However, it is only returning 11 ...
1
vote
0answers
162 views

WP_Query orderby and tax_query

My goal is to have custom posts type's posts (CPT for simplicity) from a custom taxonomy (CT for simplicity) let say CT Hometown with slug Nebraska to be listed grouped by another CT, let say ...
0
votes
0answers
27 views

Meta query not working with pre_get_posts

This works $q->set('meta_key', 'available-date_%_from'); $q->set('meta_value', '20140701'); This doesn't $q->set( 'meta_query', array( array( 'key' => 'available-date_%_from', ...
0
votes
1answer
32 views

excludeCat function reverses order of blog posts

I'm using the code below to remove category #5377 from the query on the home page. However, this code is also reversing the order of blog posts for some reason. How can I alter this code to only ...
0
votes
1answer
23 views

Grab next post title in archive page

I am using a custom query on a page to display single posts from a specific category, one post per page. Here is my current query: $results = new WP_Query( array( 'post_type' => 'post', ...
0
votes
2answers
50 views

Sort order in get_posts [closed]

I've created a custom template for a client. This is going to be a multilingual site setup on a Multisite install. As you can see under each category letter, the posts start out in alphabetical order ...
1
vote
1answer
38 views

How to get a query variable?

I have added a query variable with the following function: function add_my_query_var() { global $wp; $wp->add_query_var('myvar1'); } add_filter('init', 'add_my_query_var'); Now on a ...
0
votes
0answers
52 views

add_query_vars does not work

I have added this code in the TwentyFourteen theme's functions.php file. function add_query_vars($aVars) { $aVars[] = "msds_pif_cat"; return $aVars; } add_filter('query_vars', ...
0
votes
1answer
111 views

WP_User_Query with more than two custom meta values

I am trying to create a custom user query based on users' metadata. I have the following query created. $users = new WP_User_Query( array( 'search' => '*' . $search_name . '*', ...
0
votes
0answers
17 views

Build query from the url given

I have an ajax request coming with parameter called "next_page_url" => "URL_FOR_THE_NEXT_SET_OF_POSTS" Now I need to build a WP_Query arguments using that url to respond to that AJAX request with ...
1
vote
1answer
207 views

Create Pop-Up Box with Custom Field Content Inside the Loop

I tried this using ThickBox first, then tried using some code I had that worked on another website... Total failure. The Goal: I have a custom post type (product) with a ton of custom fields. I also ...
0
votes
1answer
32 views

Query unique author ids with published post of type job

I'm trying to come up with a simple query to return an array of unique author IDs that have a post_status of 'publish' and a post_type of 'job'. I know I can query using: $args = array( 'post_type' ...
0
votes
1answer
194 views

Retrieve posts by term id custom query

i want to retrieve custom posts using using custom query . my taxonomy is recipe_tx and terms (Beef) , (Chicken) etc in it . i have tried using SELECT p.* FROM wp_posts p, wp_term_taxonomy tt, ...
0
votes
1answer
455 views

wpdb::prepare was called incorrectly

I have this code to remove orphaned posts after deleting custom post type. It works, but this code... global $wpdb; $wpdb->query( $wpdb->prepare( "DELETE a,b,c FROM wp_posts a ...
0
votes
0answers
58 views

How to filter the terms to a special custom taxonomy?

I do have a custom taxonomy called "countries". With the code below I get for each term (country) the number of its published posts in brackets, like the following: Canada (3) USA (5) Italy (2) ...
4
votes
1answer
143 views

How to uniquely identify queries?

Today I was thinking about how to differentiate queries, mainly to create an unique identifier. In the process I played around a bit, see below code. The main idea is to do it depending on the ...
0
votes
0answers
61 views

A Depth Like Parameter For “get_posts”

Wordpress has stumped me for the first time in a very long time. I am trying to limit the depth of a get_posts call in my template. I want to get children but limit it to a depth of only 3 as I am ...
0
votes
0answers
61 views

Is MySQL query cache useful for WordPress?

Starting from MySQL 5.6, if you use InnoDB as the default engine, the query cache is now officially disabled. We've a quite moderate traffic WordPress site and experience a major downtime when we ...
0
votes
1answer
45 views

Slow query when joining wp_posts with a lookup-table?

I'm developing a map-based website and need to get posts associated with a place. Each place has a post in wp_posts and the other associated posts (images of each place etc) is associated with the ...
0
votes
1answer
28 views

Pulling values from a sepcific row in table

I'm trying to get the first and last name values for ONE person in a database where the meet certain conditions of being a team leader and having a specific project id. Because of this, it will always ...
0
votes
1answer
60 views

Need help setting up a search form for wordpress [duplicate]

I want to set up a search function as a widget in wordpress. This is the situation that I have. 1- I have 3 custom post types 1.a: Each post type has custom fields and taxonomies. I have regular ...
0
votes
0answers
78 views

Get the menu name or location of current menu item

I am having a hard time trying to get the name of the active menu and, apparently, I cannot find any solutions to this issue. Basically, I have several menus that follow this pattern: Menu Name ...
0
votes
0answers
52 views

Show posts with specific tag in a category page

I have a website which belongs to a magazine. I want do something like this: I want to create a link that refers to /category-slug/tag-slug. in that link, I want to show all posts with "specific tag" ...
0
votes
0answers
37 views

A pagination-sort-of-thing on single.php view for the custom post type

First, a quick demonstration of what I need to achieve: It would work similarly to <?php previous_post(); ?> and <?php next_post(); ?>, but also include an actual "reel" indexing all ...
0
votes
1answer
61 views

How to get list of posts from permalinks?

I am using an API which tracks metrics on parts of my site. The only useful bit it saves though is the URL (permalink). What is the most efficient way to query up all the posts that match those ...
0
votes
0answers
18 views

How to cancel a custom post type query based on existing cache file

Is there a proper way to greatly restrict the query (or remove it altogether) for a custom post type type-single.php file? Simply stated, for reasons of speed speed speed I've cached all relevant ...
0
votes
1answer
23 views

Removing a post from the results of a WP Query

We have a complicated database query and we would like to exclude some posts. We've tried to do it with SQL, but it's really complicated. The simplest solution seems to loop through the results after ...
0
votes
1answer
70 views

Sorting posts according to view counts not working

I use the code snippet below to get views count of each post on my sidebar.php . everything works but the sorting does not. also it does not get 4 posts, it only shows 1 post although I've written ...
0
votes
0answers
57 views

External json physician database to display results in WordPress

We're working on a physician network site in WordPress using the Divi template and we have most work completed. However, we've also been tasked to have a physician search that will bring up results ...
0
votes
2answers
45 views

Modify Search Query if original Query gave no results

I'm looking for a way to modify the search query if the performed query returned no results. Let's say I'm looking for "Opening times", so I go to this URL: http://mysite.com?s=Opening+times Now, ...
0
votes
1answer
210 views

How to manage a particular “order by” for get_search_query()?

How to manage in the search.php file the order of a posts search query managed with the following code <?php echo sprintf(__('%s Zoekresultaten voor ', 'website'), $wp_query->found_posts); echo ...
0
votes
1answer
56 views

Taxonomy archive template that shows posts from more than one taxonomy

I've had a fair amount of experience with WP, but this continues to make issues and could be on the brief for my next website. I'm looking for a "good" way to accomplish this task; the post screen ...
1
vote
2answers
43 views

How can I paginate this?

Been trying to use the pagination functions in wordpress with this code <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_status' => 'pending', ...
0
votes
1answer
19 views

Custom taxonomy query showing more than 4 posts

I have a custom taxonomy query setup that shows posts from the same post type and share the same taxonomy term. The markup looks as follows: <?php $terms = wp_get_post_terms( ...
-2
votes
1answer
91 views

query posts only works on the first page

I'm using Jetpack's infinite scroll function on the homepage and I only want to display posts from the category with ID 1. The problem is that my query works correctly only on the first page. On the ...
1
vote
1answer
69 views

Select two sums with single get_var statement

I am trying the following global $wpdb; $sum = $wpdb->get_var("select sum(first), sum(second) from table where id > 1"); I am unable to get the values from each request. I have tried ...
1
vote
2answers
95 views

I have over 4000 posts, will querying some of them cause performance issues?

I am wondering if querying posts like this: <?php $args = array('numberposts' => 19, 'orderby' => 'rand' ); $posts = get_posts( $args ); foreach($posts as $post) { ...
0
votes
1answer
27 views

Custom taxonomy - query returns an error

Web page in question: http://www.cambridgesca.org.uk/ExternalDirectory/searchdirectory/ Plug-in used: Search & Filter Frequencies is a custom taxonomy. Code, as follows, inserted at the end of ...
1
vote
1answer
68 views

How to delete a transient on post/page publish?

I have a transient set for a custom query. It expires in 30 days. But I also need it to expire once a new post/page is published. So that the new published post/page is available in that custom query. ...
0
votes
1answer
58 views

Pagination not working with WP_Query (creates links but no page)

The following loop gets all posts within a relevant category. It does generate a pagination URL, but it does not take me there (it just redirects back to the homepage). Would anyone know why? $paged ...
0
votes
0answers
45 views

very slow wordpress query with default query

I had been asking questions about this issue but sadly not getting the help blog at this address : http://fixapk.com Currently, the blog includes approximately 560,000 apps ( 560,000 equivalent posts) ...
0
votes
0answers
67 views

How to get video url and poster url with query in wordpress 3.9.1

[video width="400" height="300" src="UrlVideo" poster="UrlPoster" preload="none"][/video] How to get UrlVideo and UrlPoster in loop query from content posts
0
votes
1answer
77 views

Custom SQL Query passing array to WHERE p.id

I need to pass an array of post ID's to a custom SQL query I am running on a certain page. The query looks like this: $querystr3 = "SELECT *, events_startdate.meta_value AS the_start, ...
1
vote
0answers
121 views

Slow meta_query with about 4 milion record on wp_postmeta

Although optimized wordpress all the way but still very slow as follows : I have converted from LONGTEXT meta_value field to TEXT Then create INDEX for this field ALTER TABLE wp_postmeta ADD INDEX ...
0
votes
1answer
55 views

List of Events with Multiple Dates: Only NEXT Date

I am currently developing a site http://madstheatre.com that will serve as a resource for Performance and Audition information in Madison, WI. A feature that is preventing me from starting to go ...
0
votes
1answer
34 views

How to print the output of the get_num_queries function from frontend to backend?

I'm trying to develop a simple plugin and figure out how to display the number of queries executed in frontend, to an admin page (plugin options page), using get_num_queries() function. I've added ...
0
votes
0answers
133 views

Get thumbnail using wpdb from external wordpress database

I'm trying to get thumbnails from posts using a wpdb query where the wordpress database I'm querying is not the one from which the wpdb query is being called. That may be a little unclear, so here is ...
0
votes
1answer
48 views

Querying Posts by Taxonomy From Alternate Network Site

I have 5 Network sites in my WordPress multisite setup. One of which is the "primary website", which the rest of the other network sites will be retrieving data from. I am currently using ...
0
votes
2answers
115 views

get_post_meta with WP_query

I know this is a convoluted loop (inherited from someone else), and this must be pretty simple: the_permalink and the_title display OK, but why doesn't my post meta eventdatestart echo?. <?php ...