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

List custom taxonomy terms from custom field

The problem you are facing is that get_the_terms() returns an array (or false or a WP_Error-Object), not a string. So, assuming that you have multiple terms for images, you could use a code like this: if( $labels && !is_wp_error( $labels ) ) { foreach( $labels as $label ) { $labelarray[] = $label->name; } $labelstring = … Read more

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