Tag Info

New answers tagged

0

The way I see it, you have three options: Store the global search data in $_SESSION Store the global data in a transient Run the query twice, with & without the post type filter I tried storing the array in a global variable and as soon as the page refreshes with the refined search results, the array shows NULL. Of course. PHP has no "memory" ...


0

Use the pre_get_posts action to override the default query. In the admin, a date query will be the query var m in the format YYYYMM. Assuming your meta dates are stored the same as MySQL dates (YYYY-MM-DD), you can use the following: function wpse_189824_date_meta_query( $wp_query ) { if ( is_admin() && $wp_query->is_main_query() && ...


-2

to aguidis select * from table-prefix_postmeta where post_id='[order_id]' you can get order's info :)


1

I haven't run this code so there may be a syntax error, but the gist is to return userfeed-taxonomy with the terms specified that have featured category OR cities-taxonomy with the terms specified and featured category OR anything else that's not those taxonomies. It's kind of clunky, maybe there is a better way: $query->set( 'tax_query', array( ...


1

If you have a lot of categories it will be a pain to search everytime every category and check against the field value. I wrote something and I would love to know if it's correct or not 1st I wrote a function that get the option name from the value since wordpress core provide only a function that get the option value from name function ...


1

Firstly, you are invoking an infinite loop, which causes the memory exhaustion. To avoid it, put the following at the beginning of your function: // avoid infinite loop remove_action( 'pre_get_posts', __FUNCTION__ ); It makes sure the you are not hooking it into pre_get_posts over and over again, re-initiating your get_posts() call over and over again. ...


1

This is not how pre_get_posts works. The pre_get_posts action gives developers access to the $query object by reference (any changes you make to $query are made directly to the original object - no return value is necessary). https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts What you are doing is simply wrong. You don't ...


1

That is not how $wpdb->prepare works. You feed prepare a string with sprintf-like placeholders, and the appropriate replacement values. Placeholders The query parameter for prepare accepts sprintf()-like placeholders. The %s (string), %d (integer) and %f (float) formats are supported. (The %s and %d placeholders have been available since the ...


0

NOTE: This code is correct above is the solution I was looking for. I just overlooked applying it to some scripts and so I thought it wasn't working.


0

You want get_field() (which returns the value), not the_field() (which echo's the value): $var = get_field( 'menu2' );


0

Wpdb can solve the custom table problems. But tag.charity_id has to be foreign key of the charity.ID


0

Try changing the field value to term_id, since there is no id value for that option. Ref: WP_Query Taxonomy Parameters


3

No need for post IDs what has no thumbnail. Use meta query to get only those what has thumbnail. Add meta query function get_only_posts_with_images( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'meta_query', array( array( 'key' => '_thumbnail_id' ) ) ); } } add_action( 'pre_get_posts', ...


0

You have lot of issues here; Never ever use query_posts, it breaks the main query and page functionalities. You are breaking and nullifying the main query even before query_posts can have a change to do it in this line $wp_query= null As this is a shortcode (taken from your comments) and with this line, 'posts_per_page' => $num,, I believe that you ...


2

I would use a custom query like this: $amsterdamstore_args = array( 'post_type' => 'store', // This is your custom post type 'tax_query' => array( array( 'taxonomy' => 'city', // This is your custom taxonomy 'terms' => 'Amsterdam', // The term you search for 'field' => 'name', // Check against the term's ...


1

You need a custom query and loop here, at least that's how I do it. $args = array( 'post_type' =>'store', 'taxonomy' => 'city', 'term' => 'your list here' 'posts_per_page' => 5 ); $loop = new WP_Query($args); if($loop->have_posts()): while($loop->have_posts()): do stuff here endwhile; endif; You will probably want to ...


0

Try the function below to get the count of all users, and user counts based on user roles, in an array: count_users(); Output comes like this: Array ( [total_users] => 32 [avail_roles] => Array ( [administrator] => 1 [subscriber] => 28 [sub_administrator] => 1 [editor] => 2 ) ) More ...


0

Actually, you don't have to use a SQL query just some adjustments in wp_config and functions.php file in your theme. Check out this topic in Wordpress Codex: https://codex.wordpress.org/Changing_The_Site_URL


1

I understand, that you add the possibilties for developers to change the html, typical a template part. That is the point, that I think you should use the default functionality for this job. get_page_template() can be overridden via the page_template filter. A simple example for the dev to change your templates from your plugin. add_filter( ...


1

You cannot insert the do_action() inside the class like that, it's gonna give you a fatal error. Instead you could use an array $skins to store all the skin functions (as closures), and the magic method _call() to call them: class skinclass { private $skins = array(); function __construct() { $this->skins = apply_filters( 'add_skin', ...


0

The plugin User Bookmarks (discontinued now) by Pippin's Plugins did a combination: * store the "favorited" posts in user meta as serialized data * store the total favorite count in post meta as an integer This lets you sort by favorite count which is useful. You just have to change the count when people add/remove bookmarks. If you do go the "make your ...



Top 50 recent answers are included