• Resolved pixelkicks

    (@pixelkicks)


    Hi,

    I want to be able to modify the output of Post Titles, so that certain occurrences of a string are replace with another string.

    It’s not a simple case of simply changing the default post title, so how would I go about creating an action that intercepts the post title and does a simple str_replace() on it?

    Thanks,

    Chris.

    https://wordpress.org/plugins/wordpress-popular-posts/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi Chris,

    You can hook to the wpp_html filter for this. It recieves two parameters: $content, the default HTML output created by the plugin; and $post_data, an array of posts objects. While I know it’s not what you need (and probably will give you more work than you expected) it’s the only solution at the moment.

    Here’s how:

    function custom_popular( $original, $data ){
        // loop $data here and build your own HTML,
        // and echo it.
    }
    add_filter( 'wpp_custom_html', 'custom_popular', 10, 2);
    Thread Starter pixelkicks

    (@pixelkicks)

    Ok thanks, I will take a look.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Just realized I made a mistake. The filter is wpp_html, although it’ll be renamed to wpp_custom_html in the next version. Sorry about that!

    You can find here a working example. Hope it helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Modify post title via custom action?’ is closed to new replies.