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

  • Jack

    (@moxie)


    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)
  • Jack

    (@moxie)

    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… 🙂

    ifelse

    (@ifelse)

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

    Jack

    (@moxie)

    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… 🙁

    Ajay

    (@ajay)

    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

    Jack

    (@moxie)

    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…

    Jack

    (@moxie)

    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?

    vkaryl

    (@vkaryl)

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

    Ajay

    (@ajay)

    I have 1.5.1.3 and am running PHPExec perfectly.

    Jack

    (@moxie)

    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.