Support » Plugin: Archived Post Status » Feature request: “aps_prefix_the_title” hook which returns boolean value

  • Resolved Gemini Labs

    (@geminilabs)


    It would be nice to have a dedicated hook to determine whether or not to prefix archived titles with “Archived:”.

    The filter could look something like this:

    apply_filters( 'aps_prefix_the_title', true, $post_id )

    For now, this is what I use:

    add_filter( 'the_title', function( $title, $post_id ) {
        return get_post_type( $post_id ) == 'project'
            ? ltrim( preg_replace( '/^Archived:/', '', $title ))
            : $title;
    }, 13, 2 );
Viewing 1 replies (of 1 total)
  • Plugin Author Frankie Jarrett

    (@fjarrett)

    Hi @geminilabs,

    You might consider taking the opposite approach here.

    Rather than using a later hook priority to undo what the APS filter has done to the title, use an earlier hook priority to remove the APS filter entirely.

    Quick example (untested):

    add_filter( 'the_title', function ( $title, $post_id ) {
        if ( 'project' === get_post_type( $post_id ) ) {
            remove_filter( 'the_title', 'aps_the_title', 10 );
        }
        return $title;
    }, 9, 2 );
    
Viewing 1 replies (of 1 total)
  • The topic ‘Feature request: “aps_prefix_the_title” hook which returns boolean value’ is closed to new replies.