wordpress Remove WP Generator Meta Tag

by in , 0

It can be considered a security risk to make your wordpress version visible and public you should hide it.

Put in functions.php file in your theme:

remove_action('wp_head', 'wp_generator');

wordpress Remove Whitespace from Function Output

by in , 0

In WordPress, there are many functions which output things for you. For example, wp_list_pages() outputs a list of all your published pages. The HTML markup it spits out is pretty nicely formatted (meaning: has line breaks and indenting).

There are some circumstances where all that "whitespace" in the formatting is undesirable. Like 1) it's all the more characters to deliver and 2) closing "the gap" in older versions of IE.

If the function supports a way to return a string (rather than immediately echo it), you can use a regex to remove the space:

<?php
   echo preg_replace('/>\s+</m', '><', wp_list_pages('echo=0'));
?>

wordpress Remove the 28px Push Down from the Admin Bar

by in , 0

For your functions.php file:

  add_action('get_header', 'my_filter_head');

  function my_filter_head() {
    remove_action('wp_head', '_admin_bar_bump_cb');
  }

By default, if you are seeing the admin bar as a logged in WordPress user, CSS like this will be output in your head (output in the wp_head() function):

<style type="text/css" media="screen">
	html { margin-top: 28px !important; }
	* html body { margin-top: 28px !important; }
</style>

This is normally a good thing, as it doesn't cover parts of your site then with its fixed-position-ness. But it can also be weird if you use absolute positioning for things. As they will be different depending on if the bar is there or not. Using the code above to remove the bump CSS will make the bar cover the top bit of your site, but at least the positioning will be consistent.

Reference URL

wordpress Remove Specific Categories From The Loop

by in , 0

<?php query_posts('cat=-3'); ?>

<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

		<h3>

wordpress Remove Private/Protected from Post Titles

by in , 0

For the functions.php file in your theme:

function the_title_trim($title) {

	$title = attribute_escape($title);

	$findthese = array(
		'#Protected:#',
		'#Private:#'
	);

	$replacewith = array(
		'', // What to replace "Protected:" with
		'' // What to replace "Private:" with
	);

	$title = preg_replace($findthese, $replacewith, $title);
	return $title;
}
add_filter('the_title', 'the_title_trim');

wordpress Remove Paragraph Tags From Around Images

by in , 0

In case you want to have <img> in your content but not have them get "Auto P'd" like WordPress likes to do.

example of problem:

blah blah blah

<img src="monkey.jpg">

blah blah blah

turns into:

<p>blah blah blah</p>

<p><img src="monkey.jpg"></p>

<p>blah blah blah</p>

We can fix it with this:

function filter_ptags_on_images($content){
   return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}

add_filter('the_content', 'filter_ptags_on_images');

For your functions.php file, or, see Reference URL for a plugin. With this in place, we get:

<p>blah blah blah</p>

<img src="monkey.jpg">

<p>blah blah blah</p>

... meaning things like floating the images will be much easier.

Reference URL

wordpress Remove Link to the WLW Manifest File

by in , 0

Kind of pointless to include this unless you actually use Windows Live Writer to write your posts. Put this in the theme's functions.php file:

remove_action( 'wp_head', 'wlwmanifest_link');