WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Exec-PHP] Displaying PHP in my header (5 posts)

  1. mcfmullen
    Member
    Posted 3 years ago #

    So I want to used the theme Blinky with the plug-in Exec-PHP. The plan is to be able to create posts using information stored on my database.

    The plugin works when posting on the page, but for some reason it does not work for display in the header, which is theme-specific. The theme's website is of no help and the creator is not responding so I'm hoping some wizards here can help me get the header to display my php posts.

    To see what I'm talking about, visit my website. As you'll see the php echo of This is the Exec-PHP ‘Hello World’ shows in the white section of the site but does not display in the blue header section.

    The header.php file reads:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    
        <head profile="http://gmpg.org/xfn/11">
            <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
            <title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
            <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />
            <?php wp_head();?>
            <script src="<?php bloginfo('template_url'); ?>/script.js" type="text/javascript"></script>
            <?php
            $xDBArr = unserialize(get_option('Slidette_values'));
            $Slidette_Theme = $xDBArr[0];
            $Slidette_Logo = $xDBArr[1];
            $Slidette_Slideshow = $xDBArr[2];
            $Slidette_Boxes = $xDBArr[3];
            $Slidette_Twitter = $xDBArr[4];
            $xColor = $Slidette_Theme;
            if($Slidette_Theme=="") {
                $Slidette_Theme="xGreen";
            }
            if($Slidette_Slideshow=="") {
                $Slidette_Slideshow="0";
            }
            if($Slidette_Boxes=="") {
                $Slidette_Boxes="0";
            }
            $wud = wp_upload_dir();
            ?>
            <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
        </head>
        <body>
            <div class="<?php echo $Slidette_Theme;?>" id="xMain">
                <div class="xHeader">
                    <div class="xHeaderB">
                        <div class="xContent">
                            <div class="xLogo">
                                <?php
                                if($Slidette_Logo=="") {
                                    bloginfo('name');
                                }else {
                                    ?>
                                <img src="<?php echo $Slidette_Logo;?>" alt="" />
                                    <?php
                                }
                                ?>
                            </div>
                            <div class="xDescription">
    
                            </div>
                        </div>
                        <div class="xRSS"><a href="<?php bloginfo('rss2_url'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/new_rss.png" alt="" /></a></div>
                        <div class="xMenu">
                            <ul>
                                <li class="clear"><a href="<?php bloginfo('home'); ?>">Home</a></li>
                                <?php wp_list_pages('title_li=');?>
                            </ul>
                        </div>
                        <div class="xSlideshow">
                            <div class="xSlider">
                                <div class="xSliderB">
                                    <?php if(have_posts()) {
                                        query_posts('showposts=&cat='.$Slidette_Slideshow);
                                        ?>
                                        <?php while(have_posts()) { the_post(); ?>
                                    <div class="xSContent">
                                        <div class="xTitle"><?php the_title(); ?></div>
                                        <div class="xText"><?php
                                                    $xContent = get_the_content();
                                                    $xTitle = get_the_title($post->post_title);
                                                    $xFImage = xGetFirstImage($xContent);
                                                    $xContent = strip_tags($xContent);
                                                    $xContent = strip_shortcodes( $xContent );
                                                    $xContent = str_replace('[/caption]','',$xContent);
                                                    if(strlen($xContent)>400) {
                                                        $xContent = substr($xContent,0,400)."...";
                                                    }
                                                    if($xFImage=="") {
                                                        $xFImage=get_bloginfo('template_url')."/images/dog.jpg";
                                                    }
                                                    echo $xContent;
    
            ?></div>
                                        <a href="<?php the_permalink() ?>" class="read"></a>
                                    </div>
                                    <div class="xSPicture">
                                        <div class="xFeatured"></div>
                                        <img src="<?php echo $wud['baseurl']; ?>/timThumb/timthumb.php?w=276&h=223&src=<?php echo $xFImage;?>" alt=""/>
                                    </div>
                                            <?php } ?>
                                        <?php }else { ?>
        <?php } ?>
                                </div>
                            </div>
                            <div class="xSliderBar">
                                <a href="#" class="xArrowUp"></a>
                                <a href="#" class="xDotA"></a>
                                <a href="#" class="xDotB"></a>
                                <a href="#" class="xDotC"></a>
                                <a href="#" class="xDotD"></a>
                                <a href="#" class="xDotE"></a>
                                <a href="#" class="xArrowDown"></a>
                            </div>
                        </div>
                        <div class="xTwitter"><a href="http://www.twitter.com/<?php echo $Slidette_Twitter;?>"><img src="<?php bloginfo('template_url'); ?>/images/twitter.png" alt="" /></a></div>
                    </div>
                </div>

    The index.php file reads:

    <?php get_header();
    $xDBArr = unserialize(get_option('Slidette_values'));
    $Slidette_Boxes = $xDBArr[3];
    ?>
    <div class="xC">
        <div class="xLeft">
            <?php
            wp_reset_query();
            if(have_posts() && is_home()) { ?>
                <?php
                $i=1;
    
                query_posts('showposts=4&cat='.$Slidette_Boxes);
                while(have_posts()) {
                    the_post(); ?>
            <div class="xBlock<?php if(is_int($i/2)) {echo "B";} ?>">
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <p><?php
                            $xContent = get_the_content();
                            $xTitle = get_the_title($post->post_title);
                            $xFImage = xGetFirstImage($xContent);
                            $xContent = strip_tags($xContent);
                            $xContent = strip_shortcodes( $xContent );
                            $xContent = str_replace('[/caption]','',$xContent);
                            if(strlen($xContent)>190) {
                                $xContent = substr($xContent,0,190);
                            }
                            if($xFImage=="") {
                                $xFImage=get_bloginfo('template_url')."/images/dog.jpg";
                            }
                            $wud = wp_upload_dir();
                            ?>
                    <img src="<?php echo $wud['baseurl']; ?>/timThumb/timthumb.php?w=143&h=115&src=<?php echo $xFImage;?>" alt=""/>
                            <?php echo $xContent;?>
                    <a href="<?php the_permalink(); ?>">...Read More</a></p>
            </div>
                    <?php
                    $i++;
                } ?>
            <?php
            }else {
    
            }
            ?>
    
            <div class="xPosts">
                <?php
                wp_reset_query();
                if(have_posts()) { ?>
                    <?php while(have_posts()) { the_post(); ?>
                <h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
                <div class="xInfo">
                    <b>Posted By:</b> <?php the_author(); ?> <b>on</b> <?php the_date() ?> <b>in</b> <?php the_category(', ') ?> - <b>Comments:</b> <?php  comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
                </div>
                <div class="xContent">
                    <p><?php the_content('') ?></p>
                </div>
                <div class="xReadMore"><a href="<?php the_permalink() ?>"><img src="<?php bloginfo('template_url'); ?>/images/readMoreContent.jpg" alt="" /></a></div>
                <div class="xDel"></div>
                    <?php } ?>
                <?php }else { ?>
                <?php } ?>
                <div class="navigation">
                    <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
                    <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
                </div>
            </div>
        </div>
        <div class="xRight">
            <?php get_sidebar('right');?>
        </div>
    </div>
    <?php get_footer();?>
  2. ClaytonJames
    Member
    Posted 3 years ago #

    The plugin works when posting on the page, but for some reason it does not work for display in the header,

    "The Exec-PHP plugin executes PHP code in posts, pages and text widgets."

    I'm not to much of a coder, but if you want to execute php in the header, wouldn't you need to make your edits/place your code in header.php then style its appearance from the themes style sheet? I'm not sure if you would need a plugin for that, though.

  3. mcfmullen
    Member
    Posted 3 years ago #

    No. The header is dynamic and changes every time a new post is made (just like any wordpress blog). The header rotates through the last 5 posts made to the blog. As such it is supposed to copy what is posted to the content and if you look at the code, the header essentially is the same loop as that in the page.

    What's curious is that the php isn't functioning in the header for some reason, hence the request for help.

  4. ClaytonJames
    Member
    Posted 3 years ago #

    Ahh.. I think I understand now. You are trying to make the php code you place in your featured post category using the plugin, appear in the featured content slider area. In spite of the posted code, your references to "in the header" made me think you were trying to make code appear in the actual header - Hence my attempt to help - Sorry about that.

    Did you notice that your php echo "Hello World" appears in the single and index page posts, but not in the featured post blocks at the top of the page? The featured post blocks, index page and the content slider seem to have an "excerpt" characteristc in common. I guess focusing on the limitations or "excerpt" characteristics of the themes "xContent" functions may have some value, but I'm afraid it's all Greek to me.
    ...Or, it might actually be a limitation of the plugin itself.

    Sorry I've been of no help. Good luck with it!

  5. mcfmullen
    Member
    Posted 3 years ago #

    I'll try to look into that, but it's all greek to me too! Can anyone else help me out with this??

Topic Closed

This topic has been closed to new replies.

About this Topic