Set the Title of a Custom Post Type by code as Author’s Username

There’s actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name: function post_author_title( $post_title, $post ) { if( $post->post_type == ‘your_post_type’ ) { $user = wp_get_current_user(); $post_title = $user->display_name; } … Read more

Call image from post on index page?

Use like this: <?php while ( have_posts() ): the_post(); // Display post if ( have_posts() ): the_post_thumbnail(); //call image that you set in featured image in each post on right sidebar of admin panel. the_content(); //call content endif; endwhile; ?>

save_post hook – headers already sent?

Saving post doesn’t just happens. Either you are submitting a form or ajax request, which spins up new copy of WP core, which does the saving. Typically that process isn’t meant to produce output and isn’t handling it accordingly. Depending on what you want to accomplish you will have to either use pure JavaScript for … Read more

Custom meta box save values issues – Deprecated: Function ereg() and more

Try the following. Replace ereg(‘/\edit\.php’, $_SERVER[‘REQUEST_URI’]) with preg_match(‘/edit.php/’, $_SERVER[‘REQUEST_URI’]) And also change if(isset($_POST[$meta_box[‘name’].’_value’])){ $data = $_POST[$meta_box[‘name’].’_value’]; } to if(isset($_POST[$meta_box[‘name’].’_value’])){ $data = $_POST[$meta_box[‘name’].’_value’]; } else $data = “”;