0
votes
1answer
36 views

Proper way to run wp_query from inside a plugin

I am developing a plugin that needs to make a query of a custom post type and retrieve data and meta data from these posts. But anytime I run that query inside my plugin, no matter what admin new post ...
0
votes
0answers
30 views

how a query can use local parameters in plugin function?

I've wanted to add a custom post type, so i've done a plugin to put on/off this post type. i have widgets inside the plugin in order to print posts with this custom type, that call more or less a ...
1
vote
1answer
49 views

How to ensure “the_content” filter runs only for the main displayed content?

I have a plugin which adds the method to "the_content" filter. add_filter('the_content', 'myFilteringFunction', 10000); Within that function I want to add some links on the beginning and the end of ...
0
votes
0answers
151 views

Can't get query string in ajax call

I'm developing a plugin that exports to a PDF your current posts view in the admin panel. Suppose you're in a post type "product", then the url must be: edit.php?post_type=product. What I want is to ...
0
votes
1answer
357 views

Get custom wp_query search results to appear on search.php

I have a search.php page in my template which works fine when used with the native search widget, but I am making a search plugin which has a custom wp_query in it and I want those results to appear ...
0
votes
1answer
76 views

Pagination not working with custom wp_query

I am trying to make a custom search plugin but pagination does not work (it shows up with the correct number pages but does not function properly). Relevant part of the search plugin (from the main ...
0
votes
2answers
34 views

Get Posts by IDs (optionally)

I want to check if a variable contains list of post IDs, then I want to query the posts of those IDs only, but if that variable is empty then I want to display all posts. Problem: If I supply IDs to ...
0
votes
0answers
109 views

How to Display Custom Post Type's Gallery (images ) in Through WP_Query

I am trying to load an Image Slider images from a Custom Post Type image Gallery Feature. For example let say I have an Custom Post Type called banner which I can load images to it's Gallery and I ...
0
votes
1answer
49 views

Toolbar Hidden in a Virtual Page

I am trying to create a virtual page, but my admin toolbar is not showing up. This is how I am creating the virtual page: functions.php add_action('init', function() { ...
0
votes
0answers
200 views

Passing multiple variables in wp_rewrite / wp_query

i need to be able to append a custom url for my page in wordpress so far i can get it to return the first query var, but i cannot get it to return the second or third im at a loss of what to try next, ...
1
vote
1answer
1k views

How to create database table, add data, update and delete using wpdb via plugins?

I am just starting out to create plugins with database. I know to create a custom database when activating the plugin. I just want to know whether we can create tables at the front end like adding the ...
1
vote
1answer
104 views

How use %like% in sql statement wordpress

i use a like %text% statement in wordpress: SELECT * FROM location WHERE name LIKE "%on" OR name LIKE "%on%" i tried anything but it's not run: $wpdb->get_results($wpdb -> prepare("SELECT ...
0
votes
2answers
109 views

how to invoke wordpress API from other existing PHP system

We have our own php system, now we want to have a blog function. Because wordpress are widely used, so we decided to use it. And now I want to invoke wordpress's function , for example wp_insert_user ...
0
votes
1answer
266 views

WP-Snap too slow (caused by WP_Query?)

I have a website with 10.000 posts... WP Snap alphabetizes the posts and puts it out with WP_Query, but it is slow as hell, which is very frustrating. My question would be: what can I do about it? ...
0
votes
1answer
246 views

WordPress Meta Query: Relation is not working correctly

I make a custom search box and let user do search. I have added required field to my editing panel by custom meta box. I have a post which have some meta data like London as place and 13021 as post ...
0
votes
1answer
388 views

Delete data from custom table when deleting a post

I want to delete post id form my custom table, when deleting a post. I have tried this way, nothing happened. Please help. add_action('delete_post', 'delete_data'); function delete_data($post_id) { ...
2
votes
1answer
761 views

add_filter and remove_filter added before and after wp_query

I have just started with WordPress Development, and found following block of code online (in some tutorial) function filter_where( $where = '' ) { // posts in the last 30 days $where .= " AND ...
0
votes
1answer
25 views

Finding a post's slug

I'm using wp_query() to get custom posts from the database. I want to list these out as links to the entries, so I'm thinking I could use the slugs. Sadly these don't seem to be included in the ...
5
votes
3answers
1k views

Query Posts by Custom Field 'Price'

I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called ...
1
vote
1answer
80 views

how to get all the child category name in a specified category name?

Supposed the specified category name is "product", which has three layered sub-categories. The structure is like the following: product one product two product three product four I want to ...
0
votes
1answer
154 views

filter the_content, custom post type, and wp_query

I thought this was going to be quick and easy, but naturally it's turning out to be more complicated. I'm writing a simple plugin that creates a custom post type "Ad", and then puts a random ad at ...
2
votes
1answer
2k views

WP Query group/order by category name

I have a requirement for displaying a list of custom post types grouped by category, but in addition to this, each custom post is linked with a meta value (in this example lets say we have a custom ...
2
votes
2answers
1k views

Why Does get_posts() Return an Empty Set?

I'm writing a custom plugin that is initialized at init. This plugin is trying to query for some custom post types already stored in the DB. Here's my code: $args = array() $myposts = get_posts( ...
0
votes
1answer
50 views

loop and in admin header problem

I have a WP_Query loop running in a function that's attached to the 'admin_enqueue_scripts' hook add_action( 'admin_enqueue_scripts', 'rs_get_scripts'); function rs_get_scripts() { //enqueue js ...
0
votes
1answer
94 views

Making a Custom Post Type Publish Loop

I want to re-publish all previously published products of a custom post type. Let's say the post type is "events" This is what I was thinking something like this: $args = array( 'post_type' => ...
1
vote
5answers
1k views

WP_Query returns no results

I'm using wp_query to create a custom query that retrieves search results but it is returning 0 results. Here is the code: $query = 's=the&posts_per_page=5&paged=1'; $custom_query = new ...
4
votes
1answer
1k views

Register custom query args parameter for WP_Query()

I have written a plugin which can store a table of technical specifications for each post (product) in an own database table. For the search function of the site I want to add a custom parameter to ...
1
vote
1answer
267 views

using new WP_Query in save_post function alters $post

I'm trying to include a WP_Query in a save_post function for a custom post type. The query is used to check all the other posts for a custom field bh_shortcode to make sure the content of the field is ...
0
votes
1answer
66 views

Checking url from plugin

I'm trying to change the login url from wp-login.php to simply 'login'. I'd been looking through another plugins source to find ways of doing it. Some of the applicable parts that I've got so far: ...
5
votes
2answers
771 views

WP_Query leaking absurd amounts of memory

Every time I call WP_Query() in the function below, Wordpress leaks 8 megs of memory. And since I call this function a lot, things get hairy pretty quickly... :( I've tried unsetting the resulting ...
1
vote
1answer
281 views

switched from query_posts to WP_query, not working now?

So I had asked (in retrospect a pretty non-question) at A little help/cleanup from a real coder? and one of the comments was to not use query_posts and instead use WP_Query. So I did a little digging ...
0
votes
1answer
48 views

Adjust query on single

I am building an event manager. One of the template files I have is events-single.php which displays single events. At the bottom of this I have next and previous events using next_post_link and ...
0
votes
1answer
66 views

How do I query posts and have their related taxonomies returned in the results?

I have created a custom post type that contains television channel data. Each channel has its own post. I have also created a custom taxonomy of channel groups. What I want to do is query all the data ...
1
vote
1answer
487 views

AJAX search posts and pages

Im trying to make a plugin where i need to create an AJAX search. Im using the method described in http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/ to perform the ajax calls. So far ...
0
votes
1answer
2k views

How to create a dynamic page based on form data with a plugin?

I have a form that users fill out. When they finish, they are redirected to a 3rd party site to set up payment options. After completing the payment process, they are sent back to my site with a ...
1
vote
2answers
153 views

Finding posts containing matching array elements in a meta field usign WP_Query

I have a metafield, that contains a series of options and writes the results to an array in a single meta field: array([0]=>'First', [1]=>'Second', [2]=>'Third', ); I find ...
2
votes
2answers
1k views

Check for featured image in WP_Query

Is there a way to filter posts by featured image when initialising a WP_Query object? Example $my_query = WP_Query(array("has_thumbnail"=>true)); or, more ideally $my_query = ...
0
votes
1answer
235 views

How to query children by post name/slug

It appears that I can only use an ID for the param post_parent whether in WP_Query or get_children Is there a way to query for children via postnames which are more readable.
0
votes
1answer
32 views

Is there a (preferable built-in) way to check what custom queries are used in a theme?

I've build a theme using custom post-types with queries like $my_custom_post_type_query = new WP_Query( array( 'my_arg' => 'value' )); Now I'm writing a plugin where I need to do something like ...
3
votes
3answers
1k views

Creating two database tables via plugin

I'm working on a voting plugin for my site and I want to create 2 tables: one that stores votes and another that stores voter ips. In Codex it suggests to use an if statement to see if the table has ...