include wp-blog-header not working on MAMP

You’re making something completely wrong. Header comment In your main file, you need the following comment on top (ex. taken from Contact form 7): <?php /* Plugin Name: Contact Form 7 Plugin URI: http://contactform7.com/ Description: Just another contact form plugin. Simple but flexible. Author: Takayuki Miyoshi Author URI: http://ideasilo.wordpress.com/ Text Domain: wpcf7 Domain Path: /languages/ … Read more

$wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?

You have a typo in orderby, and meta_value_num is only used as an orderby value, try this: $args = array( ‘post_type’ => ‘event’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘locations’, ‘field’ => ‘id’, ‘terms’ => $location // location term id ) ), ‘meta_key’ => ‘event_date’, // this meta field stores event date in yymmdd format … Read more

$wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies

Do a tax-query and then count the result. No need for a custom query with dozens of JOINS. $posts = new WP_Query( array( ‘post_type’ => ‘MYPOSTTYPE’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘TAX_1’, ‘field’ => ‘slug’, ‘terms’ => array( ‘TERM_TAX_1’ ), ‘operator’ => ‘IN’ ), array( // etc. ) ), ‘post_status’ => ‘publish’ ); prinft( … Read more

Modify the structure of data returned by $wpdb

You can do this one of two ways, as far as I can see: Use PHP to combine the current results to the one you want. Basically: $records = array(); foreach( $results as $result ) { $record_id = $result[‘item_id’]; if (empty($records[$record_id])) { $records[$record_id][‘item_id’] = $result[‘item_id’]; $records[$record_id][‘item_name’] = $result[‘item_name’]; $records[$record_id][‘sub_items’] = array(); } $records[$record_id][‘sub_items’][] = array( … Read more

Post Bulk Update

1) Create a new page and assign a new page template to it, lets say site.com/update and update.php. Inside of update.php write you bulk mechanism: <?php // grab all your posts $parts = get_posts(array(‘post_type’ => ‘parts’, ‘numberposts’ => -1,)) // loop through every part foreach ( $parts as $part ) { // get part number … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)