WordPress.org

Ready to get started?Download WordPress

Forums

P2
apply_filters the_title missing post ID (6 posts)

  1. Janneke Van Dorpe
    Member
    Posted 11 months 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 9 months ago #

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

  3. Janneke Van Dorpe
    Member
    Posted 9 months 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 9 months ago #

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

  5. Janneke Van Dorpe
    Member
    Posted 7 months 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 7 months ago #

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

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.