making sense of admin-ajax

The function that returns the contents of that ajax request will not be in admin-ajax.php. That is the core WordPress file that handles ajax requests, but it is not used for specifying the data returned by ajax functions in themes / plugins. In the theme (somewhere), will be a line that looks like this: add_action(‘wp_ajax_myajax-submit’, … Read more

Per site configuration

You should make a plugin, that way it is portable to any theme. Generally speaking people need to stop filling up functions.php or theme files with code that is better suited for scalability and flexibility, aka a plugin.

Woocommerce with metabox plugin

Here’s the metabox code what I’m using which is working fine for me: // Add meta boxes with TinyMCE via wp_editor() function // Define the custom box add_action( ‘add_meta_boxes’, ‘product_details_add’ ); // Do something with the data entered add_action( ‘save_post’, ‘product_details_save’ ); // Adds a box to the main column on the Product post_type edit … Read more

Calling custom profile fields?

Try instead $user_contactmethods[‘work’] = __(‘I work for…’); and <?php echo get_user_meta($current_user->ID,’work’,true);?> where the array index is ‘work’ instead of ‘I work for…’, i.e. lowercase and without any spaces.

nextgen gallery: how to get picture url by gallery id

After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for somebody. global $nggdb; $get_gall_id = get_post_meta($post_id, ‘galerijos_id’, true); $gall_ids = $nggdb->get_ids_from_gallery($get_gall_id); $images = $nggdb->get_gallery($get_gall_id); foreach ( $gall_ids as $gall_id ) { echo $images[$gall_id]->imageURL .'<br>’; }

Separate table or usermeta

The obvious advantage of user meta is that you can use the WordPress API to record and retrieve these extra columns, without writing extra PHP classes or SQL queries. The wp_usermeta table is pretty well indexed, in fact, it uses one row per field (rather than one column if you use a custom table), and … Read more

How to get the db table row that has the biggest value in the meta value?

The WP_Query has a feature called meta_query. Using it allows you to either query by value or numeric value: $car = new WP_Query( array( ‘post_type’ => array( ‘cars’ ), ‘meta_key’ => ‘car_number’, ‘orderby’ => ‘meta_value_num’, ‘posts_per_page’ => 1, ‘order’ => ‘DESC’, ‘cache_results’ => true, ) ); $carNr = get_post_meta( $car->ID, ‘car_number’, true ); // Inspect … Read more

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