Delete a WordPress transient from a shortcode on Page/Post update

If you will save all data of shortcodes in one variable, you can reset it easy. Example somewhere in shortcode(pseudocode): $page_cache = get_transient(“page_{$page_id}”); if ( empty($page_cache ) ){ global $shortcode_index; $page_cache[$shortcode_index] = **some data that cached**; set_transient( “page_{$page_id}”, $page_cache, **some time** ); $shortcode_index++; **** } And then you can delete it just by page_id on … Read more

Custom Post Type Loop throws 500 error when used in widget

There are several problems in your provided code. $query -> while( have_posts() ) The WP_Query() return type is object. You are referring to a method that doesn’t exist. Instead, you should use the following: while( $query->have_posts() ) {…} wp_reset_postdata(); inside the conditional This function resets the post’s data, as it suggests. If you use it … Read more

get current custom post ID by WP_Query method

Since the AJAX can be called from anywhere, even by a search engine, you should pass the ID manually. To do this, you need to include the ID of your current page somewhere in your template. There is a common practice to include extra information in hidden input elements. You can add this hidden element … Read more

Change the CSS of the Customizer API

Definitely, you can use the customize_controls_enqueue_scripts hook to load custom CSS and JS. This is an example of making the panel 400px: File: sample-theme/css/customizer-controls.css .wp-full-overlay.expanded { margin-left: 400px; } .wp-full-overlay-sidebar { min-width: 400px; } .wp-full-overlay.collapsed .wp-full-overlay-sidebar { margin-left: -400px; } File: sample-theme/functions.php /** * Enqueue style for customized customizer. */ function sample_theme_customize_enqueue() { wp_enqueue_style( ‘custom-customize’, … Read more

How to disable the password strength meter script on reset password page?

If you only want to hide the password strength meter, you could do so via CSS. In your plugin function login_stylesheet() { wp_enqueue_style( ‘custom-login’, plugins_url( ‘login.css’, __FILE__ ) ); } add_action( ‘login_enqueue_scripts’, ‘login_stylesheet’ ); In login.css (hide box and change border-color of inputs) body.login-action-rp #pass-strength-result { display: none; } body.login-action-rp #pass1, body.login-action-rp #pass1-text { border-color: … Read more

Append HTML Using Shortcode

First things first. You shouldn’t really use echo inside a shortcode, unless there is NO way to return the value. In your case your can simply convert it to a function that returns a value: function date_important_info(){ return display_date($date); function display_date($date){ $data = ” <div id=’my-shortcode’ style=””> <span>Date:</span> <span> {$date} </span> </div>”; return $data; } … Read more

How to query for posts with a null or blank post_name?

If you want to use WP_Query: $no_title_posts = new WP_Query(array(‘name’=>”,’posts_per_page’=>-1); That will search all posts with empty name. The posts_per_page = “-1” returns all posts because by default wp returns 10 or whatever number you have selected in your admin settings. if you want to retrieve it from other posts types (default is “post”), then … Read more