WordPress.org

Forums

P2
apply_filters the_title missing post ID (6 posts)

  1. Ella Iseulde Van Dorpe
    Member
    Posted 2 years ago #

    functions.php line 306 should be

    $t = apply_filters( 'the_title', $temp->post_title, $post->ID );

    instead of

    $t = apply_filters( 'the_title', $temp->post_title );

  2. Lance Willett
    Themer
    Posted 1 year ago #

    Hi Janneke,
    The second argument isn't mandatory -- do you have a use case where it would be needed?

  3. Ella Iseulde Van Dorpe
    Member
    Posted 1 year ago #

    Hey Lance,

    I'm hooking in the title with

    add_filter( 'the_title', array( $this, 'the_title' ), 20, 2 );,

    but the $id is missing and I need it. :)

  4. Lance Willett
    Themer
    Posted 1 year ago #

    Can you explain a bit more? Why do you need the post ID?

  5. Ella Iseulde Van Dorpe
    Member
    Posted 1 year ago #

    Sorry for the late reply. I'm working on the front-end editor, and it needs to filter the title only when the $post->ID matches the $id of the title because otherwise it would filter titles from other posts that might be called inside the loop.

    https://github.com/avryl/wp-front-end-editor/blob/master/class-wp-front-end-editor.php#L351

  6. Lance Willett
    Themer
    Posted 1 year ago #

    Cool — thanks for explaining this. We'll add the ID argument in the next version of P2.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.