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

How can I get a list of latest posts outside of my WP install?

You have several options. XML-RPC http://codex.wordpress.org/XML-RPC_Support is the place to start. The API exposes a large number of methods to access WordPress data “outside” of the full WordPress context. Difficult to setup, connection requests overhead. wp-load.php Include wp-load.php to load up WordPress. You will need to chdir() into WordPress first for this to work properly, … Read more

Search not working with title and content

Edit: It appears your actual problem is searching tags and categories, hence placing the s parameter inside the tax_query. There is no way to search tags categories and other terms using only the fields provided by WP_Query. Your query doesn’t work because what you want isn’t possible with just the parameters available. Instead of asking … Read more

Include Sticky Post in Page Posts Count?

This is doable, and as I stated in a comment, you need to follow the following steps Get a count the amount of sticky posts. This can be done by simply counting get_option( ‘sticky_posts’ ) which holds the ID’s of the sticky posts in the form of an array You would also need to get … Read more

Divide Post content into separate divs for every 500 characters (or any other character counts)

get_the_content() return what’s in the editor, but wpautop filters and such are attached to the_content (which you don’t need inside your split function – just apply it later manually with apply_filters( ‘the_content’, $output ); at the end. You should as well use strip_shortcodes( get_the_content() ); before splitting it up: $output = get_the_content(); $output = wp_trim_words( … Read more

VT-resize image and display it [duplicate]

Whoa, ok let’s take a step back and use an actual WordPress function, that way your not doing anything weird like the above. Use these: http://codex.wordpress.org/Function_Reference/wp_get_attachment_image (the images) http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src (array with atributes) http://codex.wordpress.org/Function_Reference/the_post_thumbnail (featured image)

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

Duplicate posts

You can use a static class property to store a rolling list of posts that are used in previous queries. This method allows you to pass data between classes (widgets, modules, plugins, etc…), but will also work for a procedural workflow. Everything on the page that uses your intermediary class will know what posts to … Read more

How to avoid duplicate posts on front page?

Don’t use an && like that. And don’t use query_posts() in the first place (It’s meant for modifying a query, not performing a separate query!) Instead, do your first selection, then pull out the IDs of the posts in that selection and pass them into the second query. $fruit = get_posts( array( ‘posts_per_page’ => 3, … Read more

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