WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Jack
    Member
    Posted 9 years ago #

    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?

  2. Jack
    Member
    Posted 9 years ago #

    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... :)

  3. ifelse
    Member
    Posted 9 years ago #

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

  4. Jack
    Member
    Posted 9 years ago #

    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... :(

  5. Ajay
    Member
    Posted 9 years ago #

    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

  6. Jack
    Member
    Posted 9 years ago #

    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...

  7. Jack
    Member
    Posted 9 years ago #

    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?

  8. vkaryl
    Member
    Posted 9 years ago #

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

  9. Ajay
    Member
    Posted 9 years ago #

    I have 1.5.1.3 and am running PHPExec perfectly.

  10. Jack
    Member
    Posted 9 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags