I'm making my first plugin, and after following a couple of tutorials, have managed to make a custom admin page, that allows the editing of the custom text I'd like to have inserted homepage.

It currently posts whatever custom text has been saved in the settings page, but to the end of every post not on the homepage ( which I understand to be is_home() or is_front_page()).

Now I want it to insert the text that is saved in the plugins settings page to be inserted into a <div> tag that's already in my websites html, so it will basically be underneath the navigation bar, inside the header.

The custom div id is <div id="inner-category">

I just don't know and can't find anywhere, what the syntax would be to get the text to be inserted inside a <div> already within my website.

Any help is massively appreciated!

Here's the code snippet that inserts the text into every post:

add_filter('the_content', 'insert_content_here');

function insert_content_here ($content) {
    if ( is_single() ) {
        $content .= '<div id="custom_text"><p>This is bloody annoying!</p></div' . "";

The above code is what I have for my plugin and the code below is where the <div id="inner-category"> is housed: <div id="category-name"> <div id="category-inner"> <p>MY CUSTOM CONTENT HERE</p>

  • Have you seen this example? – fuxia Apr 14 '13 at 16:17
  • That seems to use a widget, but still doesn't seem to give me the placement I am after. I really need it to get it to go inside a div tag that's already within the HTML. Thank you very much, but I guess I'm still at such a level where I can't quite see if my solution is there or not. :( I do appreciate it though, I'm looking through it still, trying to find my answer, but to no avail. I mean, would I need to use an array to acheive what I'm after? As in the example the array contained <div> tags both start and end ones. So is this the function adding that in? – JohnDollop Apr 14 '13 at 17:27
  • Within what HTML? Where is the HTML generated? Is it in the post body or in a template file? – s_ha_dum Apr 14 '13 at 18:22
  • I've posted in the OP where the div I would like text to be inserted is, and it's contained within the home.php chameleon template file. – JohnDollop Apr 14 '13 at 19:03
  • I found out the way to do it, and it was via 'Child Themes'. Thanks for the help guys. Sorry if my question wasn't concise enough! =0) – JohnDollop May 10 '13 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.