Thread Starter
joshdw
(@joshdw)
Bump, my posts seem to be disappeering
Thread Starter
joshdw
(@joshdw)
I searched for over 20 hours now and i cant find a thing!
There’s a filter available just for this kind of thing, it will work regardless of whether the editor is set to HTML or Visual mode.
add_filter( 'default_content' , 'my_default_content' );
function my_default_content( $post_content ) {
$post_content = '<div class="test-default-content">Hello World!</div>';
return $post_content;
}
There’s also a further two filters available for the default title and excerpt..
default_title
default_excerpt
.. both would work in the same manner as the filter above.
Thread Starter
joshdw
(@joshdw)
Where do i add these , and thanks for your response!
Easiest place, functions.php of your theme, else just create a file with a plugin name and install it as a plugin, whichever you prefer.
Example as a plugin..
<?php
/*
Plugin Name: Set Default Post
*/
add_filter( 'default_content' , 'my_default_content' );
function my_default_content( $post_content ) {
$post_content = '<div class="test-default-content">Hello World!</div>';
return $post_content;
}
Create a file, give it a php extension (can be called anything you like), and plonk the above into the file. Upload the file to the plugins folder, then activate it via the plugins page as you would any other plugin.
Thread Starter
joshdw
(@joshdw)
Yeah i didnt know how to do this 🙂 Life saver, just added at the end of my functions file and it works perfect!
TYSM
Thread Starter
joshdw
(@joshdw)
1 Last question, is it possible to add a text, normal text underneither or above the content box?
Add new post
Textbox to enter details here
underneith that textbox: “<p><Dont forget to add picture</p>”
Well there’s no appropriate hooks, but we could use some jQuery to do it..
You can add this additional code to the above.
add_action( 'admin_head-post-new.php' , 'reminder_message' );
function reminder_message( ) {
?>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready( function($) {
$('#postdivrich').prepend("Don't forget to add a picture.");
} );
/* ]]> */
</script>
<?php
}
🙂
Thread Starter
joshdw
(@joshdw)
If i could i would rep + you now!
And i came across 1 last question,
On Dashboard, the text:
Theme News Top with 0 Widgets
You are using WordPress 2.9.2.
Anyway to edit or maybe add a line of text to that?
Thanks SO much!
Add an action to rightnow_end
and you can add content after the existing content in the right now widget.
Unfortunately there are not any other hooks available (well there’s one more, but it’s right after to the suggested one, so it’ll do exactly the same).
Example usage:
add_action( 'rightnow_end' , 'my_custom_rightnow' );
function my_custom_rightnow() {
echo 'Hello World!';
}
Hope that helps… 🙂
Thread Starter
joshdw
(@joshdw)
Worked for adding text 😀 Thanks thats all my problems solved!
Love you, no homo but really do!
Thanks a lot for helping a newbie to WP as me 😛
Josh
@mark / t31os – is there any way to define the reminder message for a specific custom post type only?
Thanks
T