Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

greatdanemaniac on "Create a default title based on post format status and or aside?"

$
0
0

Hi!
I need help with this. I'd like to have a default title based on the post formats status or aside. Aka if I select the post format "aside" in the post format metabox, the title should automatically change to i.e "Update + date". If I select another post format, the title field should stay empty and I shall fill it in myself.

I have some basic code and this works as long as I do not add the post format stuff to it. I get a default title but it's stuck no matter what post format I choose. I only want this for the post formats I mentioned.

add_filter( 'default_title', 'my_default_title', 10, 2 );

function my_default_title( $post_title, $post ){

      if(has_post_format("aside"))
    {

	$title = "Update |";

  // create your preferred title here
  $post_title = $title . date( 'F j Y' );

}
  return $post_title;
}

The titles are not supposed to be shown on my blog. I only want this in order to have a unique permalink and title for each post, instead of some number if I forget or don't fill in the title myself. I know I can use wp_insert_post_data for this as well, but I haven't seen a single proper example of how to incorporate post formats into that code, and I've googled this problem for 3-4 days now and I'm getting nowhere.

I'm a complete noob, so please be thourough with your explanation on how to make this work. Thanks in advance!


Viewing all articles
Browse latest Browse all 8245

Trending Articles