Quantcast
Channel: Topic Tag: plugin | WordPress.org
Viewing all articles
Browse latest Browse all 26892

Jan Dembowski on "Add dynamic content before the loop"

$
0
0

Glad to but I may do it in a roundabout fashion that may be more unclear. ;)

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.

Ideally WordPress would have a hook like wp_before_loop_after_head and many theme frameworks do have a hook like that. As far as I know that function doesn't exist in the stock WordPress distribution.

You want to output HTML inside the body but before the posts, titles, content, etc. Hooking into the loop_start will do that for you. But there can be many loops executed in one page view and just hooking that without some tests would put your HTML output all over the place.

What this code does is run at the start of each loop but it checks if the loop is after an action that runs in wp_head.

If that action has been executed then the function starts counting the number of times the loop is ran.

You want your HTML output at the top so that would be the first loop and if that's the case then output your HTML. I added $mh_slider_done = true; but that's really not necessary and a remnant of the code I copied.

I hope that explanation was clear if not let me know here.


Viewing all articles
Browse latest Browse all 26892

Trending Articles