Thread Starter
760110
Just as a follow-up, here’s what I’ve written already. It was a test to see if I could remove the title from password protected posts:
function really_simple_function(){
$post = &get_post($id);
$title = $post->post_title;
if(substr($title, 0, 10) == 'protected:'){
$my_title = '';
return $my_title;
}else{
return $title;
}
}
add_filter('the_title', 'really_simple_function');
What this does is remove the “Protected:” prefix to the posts that are password protected and not remove the whole title itself… some might find this actually useful, but it isn’t doing what I’d hoped. Any advances?
Thread Starter
760110
Just as a follow up, the existing plugin at http://www.schloebe.de/wordpress/admin-management-xtended-plugin/#english does as intended, just need to work out why 😉
Thread Starter
760110
As a further follow up it doesn’t appear the the Admin Management Extended doens’t work flawlessly. So i have written some PHP to modify the them, it is as follows:
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<?php
$post = &get_post($id);
if ( !empty($post->post_password) ) { //if the post has a password
if ( is_home() ) { //and if we're on the home page
//then don't print out that post at all
?>
<div class="no_content">
</div>
<?php
}else{ //we're not on the home page, so print out the post
//which would be the password form
?>
<div class="content">
<h2>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h2>
<?php the_content("...continue reading: " . get_the_title('', '', false)); ?>
<?php edit_post_link('Edit', ' | ', ' | '); ?>
</div>
<?php
}
}else{ //there is no password for the post
//so print out the actual post
?>
<div class="content">
<h2>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h2>
<?php the_content("...continue reading: " . get_the_title('', '', false)); ?>
<?php edit_post_link('Edit', ' | ', ' | '); ?>
</div>
<?php
}
?>
<?php endwhile; ?>
<?php endif; ?>
This grabs the post, finds out whether it has a password attached to it, if it is, then finds out if it is on the home page, if it is, then it just prints out a blank div (you can add some content here if you wish).
If the post has a password but we’re not on the homepage then we want to go through the normal loop and display the post (which would initially be the ‘enter password’ form).
If the post doesn’t have a password then just carry on about your normal business.
I wonder if it is possible to turn this into a plugin … ideas ?