• Currently using the Exec-PHP plugin (but all of the php execution plugins do the same thing in this case).

    You enter some code in a post:

    <?php …some stuff… ?>

    This works fine if the post is a single, but if it is an excerpt WP escapes the opening tag … like so:

    < ?php …some stuff… ?>

    /////^ pointing to the single white space/////

    Click on the “read more” and the entire post correctly processes the php code.

    Can anyone point out which filter or file does this?

    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • I would suggest looking at the_excerpt() function, although it is possible your theme may have a custom excerpt function that it is using.

    Thread Starter vonaras

    (@vonaras)

    Hi cais,

    Thanks for the lead. I am using Thesis and they might very well use a custom excerpt. I will hunt in that direction and see what I can find.

    ??

    Thread Starter vonaras

    (@vonaras)

    I switched to the Default WP Theme and the problem remains.

    Moderator James Huff

    (@macmanx)

    the_excerpt() is designed to strip everything but text out of the post. This includes, but is not limited to, HTML tags and images. Since the WordPress core is not designed to recognize PHP code in a post, I think it might be treating it as text, but I have no clue as to why it’s adding the space. Maybe it’s purposefully breaking it to keep with the text-only nature of the_excerpt().

    You could try using the_content() instead, unless you really want to display excerpts.

    Thread Starter vonaras

    (@vonaras)

    Thanks macmanx,

    This site is a real estate site and has 10 excerpts (listings) per page. It has been working fine with PHP code in the content, so you are correct – that does work. The problem only emerged when we tried to add a small PHP script before the “<!–more–>”.

    I have spent quite a bit of time trying to figure out if “the_excerpt” is doing this, but I can’t find any code that would add that space. It is a mystery.

    Thread Starter vonaras

    (@vonaras)

    I think maybe we aren’t actually using “Excerpts”.

    We use the “<!–more–>” tag to cut off the posts at the same place and then display 10 posts per page – so it seems like they are excerpts … but now that I think about it I don’t think they are.

    So if they aren’t “Excerpts”, why does WP alter the PHP line ONLY before the “–MORE–” tag?

    ??

    Moderator James Huff

    (@macmanx)

    You’ll have to take a look at the specific template file that is in use, and find out if it’s using <?php the_excerpt(); ?> or <?php the_content( $more_link_text ); ?>

    Thread Starter vonaras

    (@vonaras)

    It is using the second.

    I set up a new test blog and edited the “Welcome” post as follows:

    <?php include (ABSPATH. ‘/wolfman.php’); ?>
    <!–more–>

    Lawrence Talbot, a haunted nobleman, is lured back to his family estate after his brother vanishes. Reunited with his estranged father, Talbot sets out to find his brother… and discovers a horrifying destiny for himself. Talbot’s childhood ended the night his mother died. After he left the sleepy Victorian hamlet of Blackmoor, he spent decades recovering and trying to forget. But when his brother’s fiancée, Gwen Conliffe, tracks him down to help find her missing love, Talbot returns home to join the search. He learns that something with brute strength and insatiable bloodlust has been killing the villagers, and that a suspicious Scotland Yard inspector named Aberline has come to investigate.

    It did the same thing with the space (but didn’t process the PHP script even on the full post.

    I then installed the “exec-php” plugin and disabled the “autop” filter.

    That’s all I did – here is the test blog:

    https://test.mb542.com/TEST3/

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Which WP Filter Does this …?’ is closed to new replies.