• Resolved nsk_firefly

    (@nsk_firefly)


    Hi!
    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 ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • 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.

    -WCC

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

    Thread Starter nsk_firefly

    (@nsk_firefly)

    Thanks!!! ??

    Thread Starter nsk_firefly

    (@nsk_firefly)

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

    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.

    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.

    Thread Starter nsk_firefly

    (@nsk_firefly)

    @stvwlf

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

    Try:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    [ usual post stuff ]
    <?php
    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');
    
    	default:
    
    }?>
    <?php endwhile; ?>
    <?php endif; ?>

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

    Thread Starter nsk_firefly

    (@nsk_firefly)

    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(“https://www.somedomain.com/file.php&#8221;);
    echo ($a);
    ?>

    As it was explained here

    Thanks ??
    I hope that this solution could help anyone ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Using “php include” in the body of the post’ is closed to new replies.