How to Prevent WordPress to encode html in post?

Save post when in HTML tab of editor. It should be saved as close to what you see in editor as possible. I had run couple of quick tests and ampersands are not encoded in this case (as you want to). I am not sure how to prevent this for visual editor, because a lot … Read more

Change custom post type GUID in RSS

The feed template files call the_guid(), which calls get_the_guid(), which has a filter named (surprisingly) get_the_guid. You can hook into this filter to change the output. The filter only gets the current GUID, not the post ID, so look this up in the global variable if you need it. add_filter( ‘get_the_guid’, ‘wpse17463_get_the_guid’ ); function wpse17463_get_the_guid( … Read more

Filter have_posts()/ the_post()

Actually, you’re going about this the wrong way. Don’t filter the posts in functions.php, instead, define custom loops and include them when needed. In a simplified example, let’s say your theme only has header.php, footer.php, sidebar.php, and index.php for the structural files. Your index.php would look something like: <?php get_header(); ?> <div id=”content”> <?php if … Read more

How can I apply filters in my class that extends Walker_Nav_Menu?

apply_filters() applies a set of registered (with add_filter()) callbacks. When you apply a filter make sure its name is not one of the reserved ones, the_title looks dangerously “collissible” with other filters. Your filter application is almost correct, but the ‘modifyTitle’ bit is not required… // apply the filter apply_filters( ‘wpse31787_the_title’, $item->ID ); …instead you … Read more

Add mime types with plugin

Obviously your plugin is producing an error! More specifically, those allowed mime types are called in such a way that this error happens before WordPress actually starts sending output. The result: an error message get’s printed, then WP tries to send its headers and your error happens. Try this: <?php function wpse35410_new_mime_types($mimes) { if( ! … Read more

How to add a filter to the get_body_class function?

The body_class() function simply calls the get_body_class() and creates a HTML class string from it. function body_class( $class=”” ) { echo ‘class=”‘ . join( ‘ ‘, get_body_class( $class ) ) . ‘”‘; } So, the body_class filter applies to both functions.

Trimming a custom field to a length

The excerpt is a specific field in WordPress and is wholly unrelated to custom fields, which is why the excerpt stuff you tried has no effect. There is no built in way to trim custom fields, you have to do it manually with a bit of php: $length = 20; $text=”Lorem ipsum dolor sit amet, … Read more

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