[ad_1]
I want to add an ads unit before or after numbers of headings/part in all of my posts manually by insert Javascript code to the function php in theme child of my website
Any one can help me with this problem and tell me what code I should use.
[ad_2]
You should probably use a plugin.
Otherwise you need to filter the content and insert your script. Something like:
`add_filter(‘the_content’, function ($content){`
`if (!is_single()) return $content; //only do this for single posts`
`$div = ‘<script>your script</script>’;`
`return preg_replace(‘/</h3>/i’, “</h3>”.$div, $content, 1);`
`});`
This will place the code after the first H3 – change the final 1 in pregreplace to replace more occurences.