• Hello,
    Thank you for a great plugin.
    I would like to be able to insert an ad inside the content below an H2, and if the post doesn’t have an H2, then count 2 paragraphs and then insert the ad.
    Anyway I can do this with Ad Inserter? If it’s not possible, can I suggest this as a future option?

    Thanks,

    • This topic was modified 7 years, 8 months ago by wpmhweb.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Spacetime

    (@spacetime)

    Not exactly what you want, but you can count H2 and P tags as paragraphs:

    Automatic insertion: After paragraph
    Paragraph number: 2
    Count paragraphs with tags: p, h2

    This is too specific for an option, but I’ll consider possible solutions.

    However, you can achieve what you want with some PHP code.
    You define one block for H2 and second one for after 2nd paragraph.

    In the first code block you define some PHP constant if the code is inserted and then you check for this constant in the second block. Of course, you need to know PHP to do this.

    Thread Starter wpmhweb

    (@wppit)

    The first solution is what I’ve been using, but unfortunately as you also said it doesn’t achieve what I’m trying to do.
    Now for the second solution, will this be something that I need to write in the functions.php file? Or where do I need to define them?

    Thanks,

    Plugin Author Spacetime

    (@spacetime)

    No, the PHP code should be in code blocks. But don’t do it unless you have experience with PHP.

    Anyway, I’m considering other, more user friendly options, to achieve such insertions.

    Thread Starter wpmhweb

    (@wppit)

    Thanks ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘If H2 exists do first, if not then insert in 2nd paragraph’ is closed to new replies.