I’m developing a content slider for WordPress and I would know how is possible to put this content slider (as html content) into the body before the loop.
I tried to filter the content with add_filter('the_content', 'functionName)
, but I get the content slider before each post.
If you use
add_filter('the_content')
, your function will be called everytime the content of a post is output, whether a single post or a series of posts in a loop. If you need to “hook” before any post content is output in a page, the only dynamic parts of all WP themes you can reach areget_header()
orget_sidebar()
(or eventget_footer
). So your best luck would be not to use a filter with the content, but an action, with get_header, like this :The problem is that this gets executed before header.php is called, and usually, the
body
tag is opened in header.php…That is if you cannot modify the theme itself. Otherwise, you can easily add an action in the theme itself and execute it where you want.
Another technique would be to add your html content after document is ready, through JavaScript which you can output in the footer.