include some text in the begin of content

I have this code on file fuctions.php.

function diww_add_post_content($content) {
	if (is_single() || is_page()) {
		$content .= '<br><p><div id="newsletter-box terms">? ?????????? ???? ???????????? ?????????. ???????? ???????? ????  <a title="???? ??????." href="">????? ??????</a></div></p>';
	}
	return $content;
}
add_filter ('the_content', 'diww_add_post_content', 0);

It is for the end of the content.
How can i make it to show in the begin of the content. pages and posts?
Thanks a lot

  • Jude
    • DEV MAN

    Howdy @nicolas

    Here you go ..

    function diww_add_post_content($content) {
    	if (is_single() || is_page()) {
    		$content = '<br><p><div id="newsletter-box terms">? ?????????? ???? ???????????? ?????????. ???????? ???????? ????  <a title="???? ??????." href="">????? ??????</a></div></p>'.$content;
    	}
    	return $content;
    }
    add_filter ('the_content', 'diww_add_post_content', 0);

    Hope that helps ( I've re written slightly)

    Cheers
    Jude

  • Jude
    • DEV MAN

    Hi again @nicolas

    function diww_add_post_content($content) {
    	if (is_single() || is_page()) {
    	$top = "Put top HTML here";
            $bottom = "Put bottom HTML here";
            $content = $top.$content.$bottom;
    	}
    	return $content;
    }
    add_filter ('the_content', 'diww_add_post_content', 0);

    Just put your HTML inside the $top and $bottom and your are set

    Cheers
    Jude

  • nicolas
    • The Bug Hunter

    thanks a lot.
    can you tell me if that is correct? it is working well.

    function diww_add_post_content($content) {
    	if (is_single() || is_page()) {
    		$content = '<br><p><div id="id">?   <a title="??." href="">?</a></div></p>'.$content;
    		$content .= '<br><p><div id="newsletter-box terms">? ?????????? ???? ???????????? ?????????. ???????? ???????? ????  <a title="???? ??????." href="">????? ??????</a></div></p>';
    
    	}
    	return $content;
    }
    add_filter ('the_content', 'diww_add_post_content', 0);

    Thanks a lot

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.