Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Johan

Show post ID in the title column

Hi, because I am not using the title field for my custom posts I would like to replace the post titles with the post ID’s. Is there an easy way to do this?

6 years, 3 months ago
Johan

For future reference; it seems that the title field cannot be modified because it is generated by WordPress and not by the admin columns pro plugin, I have implemented this hack-ish workaround:


// Change post title
function ggs_change_title_column ( $content ) {
	global $post;
	if ( $post->post_type == 'ggs_order' ) {
		return str_replace( 'Auto-draft', $post->ID, $content );
	} else {
		return ( $content );
	}
}
add_filter ( 'the_title', 'ggs_change_title_column');

So I am doing a replace for the automatically generated page title when outputting the_title for my custom post type ‘ggs_order’.

6 years, 3 months ago
Tobias
Developer

Hi Johan,

With Admin Columns you can just change the column type of “Title” to an post “ID” column. Here is a quick demonstration video: http://recordit.co/j0gxvax4MX.

6 years, 3 months ago
Johan

Hi Tobias, thanks for your reply and the demonstration video. I had tried changing the column type, but then the edit/view links are not visible when hovering over the links.

I ended up creating an automatic numeric post title by using the wp_insert_post_data filter so the issue is now solved.

6 years, 3 months ago

You must be logged in to reply to this topic.