Add_filter to current page in WordPress

392 views Asked by At

I have problems with add_filter functions in WordPress.

Code:

function ftp_content_filter($content) {

    $content = preg_replace("#\[form_to_pdf\]#si", ''.ftp_content().'',$content);

return $content;
}
add_filter('the_content', 'ftp_content_filter');

It's working , but i have ftp_content(); on every page.

Code [form_to_pdf] is only in page_id=3 and I want to have this function only on this page.

I thnik that 'the_content' is content from every page, so how can i filter only single (current open) page?

Thanks for help.

1

There are 1 answers

0
Nabil Kadimi On

This way, you shortcode should work anywhere shortcodes do:

function form_to_pdf_func() {
     return ftp_content();
}
add_shortcode('form_to_pdf', 'form_to_pdf_func');