Skip to content

Instantly share code, notes, and snippets.

@martijn94
Last active November 28, 2024 13:43
Show Gist options
  • Select an option

  • Save martijn94/484ef79ffbcb420549327454a746f88b to your computer and use it in GitHub Desktop.

Select an option

Save martijn94/484ef79ffbcb420549327454a746f88b to your computer and use it in GitHub Desktop.
Snippet to add post state to a WordPress page
<?php
//======================================================================
// Add post state to the projects page
//======================================================================
add_filter( 'display_post_states', 'ecs_add_post_state', 10, 2 );
function ecs_add_post_state( $post_states, $post ) {
if( $post->post_name == 'edit-profile' ) {
$post_states[] = 'Profile edit page';
}
return $post_states;
}
@akshuvo
Copy link
Copy Markdown

akshuvo commented Apr 8, 2019

Thanks

@MattFisch
Copy link
Copy Markdown

Nice, thanks! Works perfectly.

@onur-km
Copy link
Copy Markdown

onur-km commented Dec 21, 2020

ty!!

@raddougall
Copy link
Copy Markdown

Hey guys, looks like just what I need. Where are you adding this though?

@martijn94
Copy link
Copy Markdown
Author

Hey guys, looks like just what I need. Where are you adding this though?

You can place it in your functions.php

@raddougall
Copy link
Copy Markdown

Hey guys, looks like just what I need. Where are you adding this though?

You can place it in your functions.php

Thanks. I had tried it there and it didn't work, hence my question. But then between typing that and your reply it started working... think I had some mixed up branches!

Good work though. Exactly what I needed and working perfectly now.

@toongeeprime
Copy link
Copy Markdown

Works perfectly - used it in a plugin. Thanks.

@EinLinuus
Copy link
Copy Markdown

Exactly what I needed, thank you!

@jahidcmt4
Copy link
Copy Markdown

Good work, Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment