HTML code in Custom field

UPDATED ANSWER The correct function to use in context to WordPress and its intended API for this purpose is; esc_textarea Thus your code would reflect something like this; <textarea><?php echo esc_textarea($images);?></textarea> Although htmlspecialchars and htmlentities are valid to use, and even though esc_textarea wraps htmlspecialchars anyway, its more appropriate to use the official API call. … Read more

Post X of Y in single.php / sidebar.php

class MY_Post_Numbers { private $count = 0; private $posts = array(); public function display_count() { $this->init(); // prevent unnecessary queries $id = get_the_ID(); echo sprintf( ‘<div class=”post-counter”>Post number<span class=”num”>%s</span><span class=”slash”>/</span><span class=”total”>%s</span></div>’, $this->posts[$id], $this->count ); } private function init() { if ( $this->count ) return; global $wpdb; $posts = $wpdb->get_col( “SELECT ID FROM $wpdb->posts WHERE post_status=”publish” … Read more

Single post comment template not working

Here’s 2 solutions i tested: Try adding support for comments in your custom post type code ‘supports’ => array( ‘comments’ ), You could also use add_post_type_support add_action(‘init’, ‘wpsites_comments’); function wpsites_comments() { add_post_type_support( ‘events’, ‘comments’ ); } Code Source

Disable Single Post View for Specific Taxonomy on Custom Post Type

I use template_redirect hook for this purpose. I suppose rented in your question is not taxonomy itself, but one term of some taxonomy. function my_page_template_redirect() { if( is_singular( ‘rentals’ ) && has_term(‘rented’, ‘your taxonomy name’) ) { wp_redirect( home_url(), 301 ); exit(); } } add_action( ‘template_redirect’, ‘my_page_template_redirect’ ); Before page rendering, WP checks if CPT … Read more