[resolved] Using "php include" in the body of the post (10 posts)

  1. nsk_firefly
    Posted 5 years ago #

    Is it possible to use php include in the body of the post?
    I'm trying to do it, but i don't undestand if i'm making a mistake or if it's impossible to do it.
    I would like to includ (with php) the signature in every post, because if i would like to change my signature, i hadn't to modify every post.

    Thanks :)

  2. WatchCount.com
    Posted 5 years ago #

    You can do it if you install the Exec-PHP plugin. It's a pretty popular plugin and should get you where you want to go.


  3. esmi
    Forum Moderator
    Posted 5 years ago #

    Only if you use one of the PHP plugins such as Exec PHP. Alternatively, you could include your sig file in single.php.

  4. nsk_firefly
    Posted 5 years ago #

    Thanks!!! :)

  5. nsk_firefly
    Posted 5 years ago #

    I tried to use php but i found that Exec-PHP allows php only in the pages and not in the posts (articles).
    Is it correct?
    Is there a way to insert php in the articles?

    Thanks :)

  6. esmi
    Forum Moderator
    Posted 5 years ago #

    I've not used any of the PHP plugins myself, so I'm afraid it's just a case of trying the different plugins until you find one that suits your needs.

  7. stvwlf
    Posted 5 years ago #

    If you are including your sig in every post, and you want them dynamic, meaning when you change your sig even old posts are affected, you are much better off adding the sig to the post template files than adding the sig in every single post. You would not have to think about it again at all. It will just automatically appear at the bottom of every post.
    Put the include you want add in the post in the template file.
    single.php for single page with comments
    index.php for posts page
    archive.php for categories, tags, archives etc.

  8. nsk_firefly
    Posted 5 years ago #


    The problem is that there are 4 differet authors and the sign is not the same :'(

  9. esmi
    Forum Moderator
    Posted 5 years ago #


    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    [ usual post stuff ]
    switch ($post->post_author) {
    	case 2:
    	include(TEMPLATEPATH . '/fred-sig.php');
    	case 3:
    	include(TEMPLATEPATH . '/bob-sig.php');
    	case 4:
    	include(TEMPLATEPATH . '/tom-sig.php');
    	case 5:
    	include(TEMPLATEPATH . '/john-sig.php');
    <?php endwhile; ?>
    <?php endif; ?>

    The numbers (2, 3, 4 and 5) refer to the ids of the various authors.

  10. nsk_firefly
    Posted 5 years ago #

    Thaks to all!
    I've solved the problem.
    I installed the plug-in PHP Execution, then i tried to use the function "php include", but there was an error:

    Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/user/public_html/page.php on line xx

    So, i solved the problem using this code for inclusion:

    $a = file_get_contents("http://www.somedomain.com/file.php");
    echo ($a);

    As it was explained here

    Thanks :)
    I hope that this solution could help anyone :)

Topic Closed

This topic has been closed to new replies.

About this Topic