wordpress Remove Specific Categories From The Loop
<?php query_posts('cat=-3'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h3>
<?php query_posts('cat=-3'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h3>
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');
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.
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');
You can remove or change the <ul>
container that you get by default with wp_nav_menu
(codex) through parameters, but you can't remove the <li>
elements that wrap each menu item. This is how you can actually remove them:
$menuParameters = array(
'container' => false,
'echo' => false,
'items_wrap' => '%3$s',
'depth' => 0,
);
echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
add_filter( 'use_default_gallery_style', '__return_false' );
You might want open registration on your WordPress site so that (for one small example) people can log in and leave comments on things without needing to type their name/url/email every time. But these users probably don't need to see the whole top admin bar as there likely isn't much use in it for them. Although do be sure to provide a link to edit their profile and log out.
This would be for your functions.php file or functionality plugin:
add_action('set_current_user', 'cc_hide_admin_bar');
function cc_hide_admin_bar() {
if (!current_user_can('edit_posts')) {
show_admin_bar(false);
}
}