Copy price categories to custom field

paste this code in you theme’s function.php file //get all categorie ID’s in to array $args = array( ‘child_of’ => 3678); // Parent category ID $categories = get_categories( $args ); $cat_array = array(); foreach ($categories as $category) { $cat_array[] = $category->term_id; } $Query_args = array( ‘category__in’ => $cat_array, ‘post_type’ => ‘YOUR_POST_TYPE_NAME’ ); $new_query = new … Read more

WordPress tables and aliases?

‘re’ is the alias you give to EVENT_ESPRESSO_RECURRENCE_TABLE. The error you’re seeing is probably because the EVENT_ESPRESSO_RECURRENCE_TABLE constant isn’t defined. Do a var_dump( $wpdb->last_query ) just below that code to see the final SQL statement.

WordPress $wpdb get posts from category and sort by custom meta

First, you shouldn’t use NOW() in select queries since NOW() returns the current date and time to the split second. In other words: This query will never land in the cache. And you can use the WP_Query with filter of posts_where eg: function filter_event_where( $where=”” ) { $date = date(‘Y-m-d’); $where .= ” AND posts.post_date … Read more

Query posts by custom taxonomy and sort by post_modified

The WP_Query function can be used on custom taxonomies and post types and is probably easier than querying the database directly. The following should do what your looking for: <?php $query_hot = new WP_Query( array( ‘post_type’ => ‘vacancy’, ‘field’ => ’18’, // You can use the ID or slug here ‘orberyby’ => ‘modified’, ‘posts_per_page’ => … Read more

Inserting data into MagicFields using mysql queries

I had the same problem but I was successful importing from an self produced xml (for the postmeta). <wp:postmeta> <wp:meta_key>telefono</wp:meta_key> <wp:meta_value><![CDATA[$tel_azienda]]></wp:meta_value> </wp:postmeta> The problem was that after that the data were not available to use with MF, I’ve solved it with this mysql query: INSERT IGNORE wp_mf_post_meta (`id`, `group_count`, `field_count`, `post_id`, `field_name`, `order_id`) SELECT `meta_id`, … Read more

Custom SELECT Query With Multiple Meta Values (Ordering Problem)

I believe you can achieve this with WP_Query and avoid the custom SQL: $today = date( ‘Y-m-d’ ); $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘ID’, ‘terms’ => 15 ) ), ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘event_enddate’, ‘value’ => $today, ‘compare’ => ‘>=’ ) ), ‘meta_key’ … Read more

Force Users To Relogin

The wp_logout function will log a user out. Here’s an example that will log someone out and redirect to the login page when the url contains the query string ?my_logout_flag: add_action(‘init’, ‘wpse52743_check_logout’); function wpse52743_check_logout(){ if( isset( $_GET[‘my_logout_flag’] ) ) { wp_logout(); wp_redirect( wp_login_url() ); } }