• I’d like to display an image beneath the page title, but only on the front page.

    I’ve achieved this by including the following in index.php

    <?php if (empty($_GET) && empty($_POST)) { ?>
    <img src="pic.jpg" alt="Cover picture"/>
    <?php } ?>

    However, hacking at index.php feels a bit hacky, and I wondered whether anyone could suggest a way to implement this as a plugin.

    I experimented with adding a filter to bloginfo() — but this affects other areas of WP (such as the title in HEAD)

Viewing 7 replies - 1 through 7 (of 7 total)
  • Don’t know if I understand you’r request correct, and I don’t know whether this will work… but you can try to save this as a plugin and see what it does:

    <?php

    /*
    Plugin Name: the name
    Plugin URI:
    Description: what it does
    Version: 0.1
    Author: your name
    Author URI:
    */

    function image($content) {

    if (empty($_GET) && empty($_POST)) { ?>
    <img src=”pic.jpg” alt=”Cover picture”/>
    <?php echo $content; }
    else echo $content;

    }

    //the registering//

    add_filter(‘the_content’, ‘image’);

    ?>

    If this does’nt work or doesn’t do what you wanted, I’ll check back tomorrow for further specifications.

    Oh yeah, there’s already one mistake now that I look at it. 🙁

    else echo $content;

    should be

    else { echo $content; }

    Thread Starter ukslim

    (@ukslim)

    Thanks, but it looks like I was too vague describing what I wanted.

    I wanted the image to appear between the blog title and The Loop — but only on the front page. If I understand your suggestion, it’s going to put an image on every post.

    http://www.hartnup.net/wordpress demonstrates the effect I’m after — achieved by hacking index.php as described in the top post.

    I don’t think a plugin will suffice in this case. Your only shot will be in editing index.php. It’s not “hacky” but the way it is. Index.php was designed to be hacked and customized the way you want. Just besure to not overwrite it when upgrading later in life (at least keep a back up too.)

    tg

    Whooops… got a little trigger happy.

    Tg

    I too think modifying the index.php is the way to go. I wouldn’t know how this can be done throug a plugin.

    Thread Starter ukslim

    (@ukslim)

    Thanks — if you reckon editing index.php is fair game, then I’m happy 😀

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Extra content on front page’ is closed to new replies.