WordPress.org

Support

Support » Plugins and Hacks » Using PHP inside posts: loosing the </a> tag!

Using PHP inside posts: loosing the </a> tag!

  • I’ve tried using the runphp or the exstatic plugin to put some phpcode inside my posts. The code is functioning fine, and I can get a list of links this way to popupimages. But the code is not complete. I use this code:

    < ?php
    for ($i=1;$i<=9;$i++) {
    echo "<a href="/2005/images/image$i.jpg" onclick="window.open('popup.htm?/2005/images/image$i.jpg','','resizeable=1,width=640,height=480'); return false"><img src="/2005/images/thumb-image$i.jpg" alt="imagename" class="photo" /></a>";
    }
    ?>

    but whenever I try to save the post, it will abandon the closing tag for the link </a>. This goes for both of the plugins, causing the rest of the page to function as one big link.

    Any idea what can cause this problem?

Viewing 9 replies - 1 through 9 (of 9 total)
  • By the way, I noticed two things: When I correct the code directly inside the database the code stays OK … until I open the post in the admininstration area and save it again, then there is a space placed between the opening tags of php: < ?php and the closing tag </a> has dissappeared again.

    Hope someone has a clue… 🙂

    Whilst I don’t use either of the two plugins, your mixing of double and single quotes (i.e. ” and ‘ ) look very suspicious indeed…

    Thanks for the tip, but that’s not causing it. I just tried it again with a very simple test:

    <?php
    echo "<a href=\"#\">link</a>";
    ?>

    The same things happen here… 🙁

    Try this:

    <?php for ($i=1;$i<=9;$i++) { ?>
    <a href="/2005/images/image$i.jpg" onclick="window.open('popup.htm?/2005/images/image$i.jpg','','resizeable=1,width=640,height=480'); return false"><img src="/2005/images/thumb-image$i.jpg" alt="imagename" class="photo" /></a>
    <?php } ?>

    I use PHPExec on my blog to display php

    You gave me good hopes there… for a moment, but this doesn’t work at all. Tried to put the $i between there own <?php ... ?> tags, but this also didn’t work. I’m puzzled because it doesn’t work with both those plugins. I’ll try PHPexec…

    Damn, can’t use PHPexec, because I’m running wp 1.5.1.3…

    But I’m getting closer:

    Just saw that when I clear the last slash (for xhtml-compliance) within class=\"photo\" />"; and then save the post, wordpress ‘repairs’ my fault. So I guess I could try finding a plugin that let’s me strip the basic markup that wordpress puts over my posts?

    You can uncheck the box that tells wp to correct invalidly nested XHTML in Options, see if that helps…. That’s in Options, Writing….

    I have 1.5.1.3 and am running PHPExec perfectly.

    vkaryl, you’ve got it! Now it works ok. So now I have to see if there is a plugin out there that gives me the opportunity to stop the xhtml correction on a per post basis.

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Using PHP inside posts: loosing the </a> tag!’ is closed to new replies.
Skip to toolbar