Creating a custom menu/widget area

I’m going to assume you’re using Twenty Eleven theme, or another theme that supports child themes. If you’re using a custom theme, then you can just edit the existing Functions.php and add your additional functionality there, and then edit the existing Style.css. However, if your situation is different, please post back, and I’ll update to … Read more

wp_editor not saving data, and text area showing html tags

There are a number of things going wrong in your code. I had to install it to see them all. First, You don’t want global $post. save_post will pass the post ID. Add a parameter to your callback. function save_points($post_id){ update_post_meta($post_id, “category”, $_POST[“category”]); update_post_meta($post_id, “brand”, $_POST[“brand”]); update_post_meta($post_id, “features”, $_POST[“features”]); update_post_meta($post_id, “holds”, $_POST[“holds”]); } Note: that … Read more

Multiple relationships in a query

Unfortunately, meta queries do not support a combination of AND & OR. But what you can do, is make two queries, one for each rule, then combine the results. $group_1 = get_posts( array( ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘meta_query’ => array ( array ( ‘key’ => ‘field1’, ‘value’ => ‘data1’, ), array ( ‘key’ … Read more

Update Custom post field by Ajax on cached site

I’ve spotted some errors here: jQuery.ajax({ type: “POST”, contentType: “application/json; charset=utf-8”, // default: ‘application/x-www-form-urlencoded; charset=UTF-8’. you can not set url: “http://localhost/wp-admin/admin-ajax.php”, // if you have correctly enabled ajax in wp, you should use the object you set up with the url data: “{‘action’:’get_PostViews(” + idpost + “)’}”, // you can use a PlainObject notation, so … Read more

How to save media files under custom folder without changing wp-config.php or changing media settings

Here is simple function to create your own sub directory for every upload. function kv_custom_image_dir( $pathdata ) { $subdir=”/uploads_img”.$pathdata[‘subdir’]; $pathdata[‘path’] = str_replace($pathdata[‘subdir’], $subdir, $pathdata[‘path’]); $pathdata[‘url’] = str_replace($pathdata[‘subdir’], $subdir, $pathdata[‘url’]); $pathdata[‘subdir’] = str_replace($pathdata[‘subdir’], $subdir, $pathdata[‘subdir’]); return $pathdata; } add_filter( ‘upload_dir’, ‘kv_custom_image_dir’ ); From my above code, I changed my images folder as uploads_img, you can change … Read more