WordPress.org

Ready to get started?Download WordPress

Forums

add_filter before homepage loop (3 posts)

  1. martongergo
    Member
    Posted 4 years ago #

    Hello everyone,

    I'm trying to add a custom filter with a plugin I'm creating to show a box on the front page, just before the Posts loop, but after the header. Is there a hook for that? I'm searching for 4 hours now and I couldn't find the hook I'm looking for.
    This is my code:

    function norilsk_filter($content) {
    	if (is_single())
    		return $content.box1().style();
    	elseif (is_home())
    		return $content.box2().style();
    	else
    		return $content;
    }
    add_filter('comments_template','norilsk_filter');
    add_filter('the_header','norilsk_filter');
  2. s_ha_dum
    Member
    Posted 4 years ago #

  3. martongergo
    Member
    Posted 4 years ago #

    Hello there!

    If I use add_filter('loop_start','norilsk_filter'); it displays where it should, but stops the post loop.

    No articles are displayed on the frontpage only my box.

    There is something I should write in the code so it continues with the loop?

Topic Closed

This topic has been closed to new replies.

About this Topic