• Hello,

    I would like to create a plugin that will insert a text just before the closing </article> tag in a wordpress page or post. I already found a solution using javascript to solve the problem, but I want code it with php because it didn’t really work in javascript.
    is there a way to do this with php wordpress?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    If you want to write something at the end of a post’s content, you’d use a hook on the_content(). You could put this in a simple plugin or in your (child) theme’s functions.php. See https://pippinsplugins.com/playing-nice-with-the-content-filter/, too.

    Moderator bcworkz

    (@bcworkz)

    To be a bit pedantic, “the_content” filter can certainly let you add more content after post content, but it might not be precisely right before the closing </article> tag. There are likely intervening closing div tags and possibly a post footer section before the closing article tag. What actually happens is theme dependent and dependent on which template is being used.

    If your insertion must really be precisely just before the closing </article>, unless your theme provides a handy hook for this, you’ll likely need to customize the template and keep it in a child theme.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘how to write before the balise article in php wordpress’ is closed to new replies.