wp_update_post onclick button using ajax

No no no! Never POST or link directly to a custom PHP file – WordPress won’t be loaded, and to load it manually yourself means making huge assumptions about the file hierarchy. Use the ajax API, which exists specifically for this reason: $.ajax({ url: “<?php echo esc_js( admin_url( ‘admin-ajax.php’ ) ) ?>”, type: “POST”, data: … Read more

Use /prefix/postname as a slug in post_name?

Well it turns out you can’t use a slash (“https://wordpress.stackexchange.com/”) in the slug but I found a solution from How to set permalink structure via functions.php, set the permalink structure in your theme’s functions.php file add_action( ‘init’, function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure( ‘/episode/%postname%/’ ); } ); It will add /episode/ before the post slug

Inline style HTML attribute is being stripped from all elements of a post

This is because what you’re trying to do trips a security feature, post content is passed through wp_kses_post to strip out dangerous tags Administrators however, have the unfiltered_html capability, which allows them to put arbitrary dangerous HTML in content and titles. This is why you’re able to insert the tags via the editor. This still … Read more

How to automatic update date and time when save custom post type

Using your example link, I just added an IF to check for post_type. function reset_post_date_wpse_121565($data,$postarr) { // var_dump($data,$postarr); die;// debug if($data[‘post_type’] == ‘new_cpt’){ $data[‘post_date’] = $data[‘post_modified’]; $data[‘post_date_gmt’] = $data[‘post_modified_gmt’]; return $data; } } add_filter(‘wp_insert_post_data’,’reset_post_date_wpse_121565′,99,2);

Updating posts exceeds maximum execution time

You do have a large amount of posts which will crash your server (due to maximum execution time being exceeded) with such an expensive operation. We will need to run this in a much more cleverer way. First of all, we would want to get all posts, except revision and nav_menu_item. Revision post_names are build … Read more

Clear cache on post of one type when something happens to post of other type

I suppose a quick and dirty way to achieve what you want is to clear the entire site cache, something like this: function clear_rocket_cache_on_post_save() { rocket_clean_domain(); } add_action( ‘save_post’, ‘clear_rocket_cache_on_post_save’ ); Otherwise you’ll need to do a query to get the matching post, something like this should work: function clear_rocket_cache_on_post_save( $post_id ) { // $result_id … Read more

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