Debugging an error: wp_enqueue_style was called incorrectly

In other words, you should not perform a wp_enqueue_style which is not hooked to wp_enqueue_scripts. Your wp_enqueue_style should be in a function, and you should hook that function to wp_enqueue_scripts like in the following example: function wpse88755_enqueue(){ # call wp_enqueue_style here } #hook the function to wp_enqueue_scripts add_action( ‘wp_enqueue_scripts’, ‘wpse88755_enqueue’ );

Is it possible to get a theme customizer setting from wp.customize using jquery?

Not sure what you try to accomplish, but you can get a value by key using the wp.customize object: wp.customize.value(‘show_on_front’)(); wp.customize.value(‘blogname’)(); …. sorry no jQuery here, just javascript, and yes, the extra () are intentional. Edit: Full overview of all settings: wp.customize._value; console.log(wp.customize._value); Edit II: different approach: a) lookup all available settings by using console.log(wp.customize._value); … Read more

Get recent posts with thumbnail

Actually, the condition is always returning false because you are not passing the post id to the function has_post_thumbnail() and the function always getting the default value which is null. has_post_thumbnail( $recent[“ID”] ). Same with the function get_the_post_thumbnail(). get_the_post_thumbnail( $recent[“ID”] ). $args = array( ‘numberposts’ => ‘3’ ); $recent_posts = wp_get_recent_posts($args); foreach( $recent_posts as $recent … Read more

what is the use of esc_attr() function?

esc_attr() is written specifically for escaping a string that is to be used as an html attribute, which means also escaping single and double-quote characters etc. In general, it’s better to use the data validation API that WP provides rather than the generic PHP functions.

Forcing all posts associated with a custom post type to be private

You can hook onto save_post, wp_insert_post or wp_insert_post_data to modify the post object prior to it being inserted or saved. Using save_post or wp_insert_post the callback would need to declare two args and would receive the post object as the second incoming variable.. (and i’m showing you to cover the alternatives, TheDeadMedic’s example would be … Read more

Load post with a different template?

you can do it like this: //add my_print to query vars function add_print_query_vars($vars) { // add my_print to the valid list of variables $new_vars = array(‘my_print’); $vars = $new_vars + $vars; return $vars; } add_filter(‘query_vars’, ‘add_print_query_vars’); then add a template redirect based on that query_var: add_action(“template_redirect”, ‘my_template_redirect_2322’); // Template selection function my_template_redirect_2322() { global $wp; … Read more

delete uploaded file

Use wp_delete_attachment( $post_id ) if you have used wp_insert_attachment() before. $post_id is the attachment ID. If you haven’t used wp_insert_attachment() a simple … unlink( $upload[‘file’] ); … will do it.