Forums

Have Text Only Appear on Homepage (20 posts)

  1. MacGuy22
    Member
    Posted 4 years ago #

    I would like a block of text under my header and above my posts to only appear on the homepage. Currently I have the text inserted in my templates index.php, so it appears on every page. How can I get the block of text to only appear on the homepage and nothing else? I am running Wordpress 1.5.1 and FastTrack theme. My blog is located at http://www.zachkarst.com/wp. I have searched on Google and the Wordpress forums but can't find a solution to my problem. All I have found is a plugin that will make a full static homepage. All help would be greatly appreciated.

  2. Minna
    Member
    Posted 4 years ago #

    Well, putting
    <?php if ( is_home() ) { ?> <?php } ?>
    around the block of text keeps it off of archives and things, but it'll show on the subpages of main page

    Edit Oh yeah, using if (is_home() and !is_paged()) works by not showing the text on subpages, if you want that

  3. MacGuy22
    Member
    Posted 4 years ago #

    Thank you for the code, I used it and it does keep the text off the archive pages. I still would like to have the block of text only appear on the homepage. If anyone else could help me out please post, so I can get this matter solved. I know everyone here is very knowledgeable so it won't be too hard. Thank You.

  4. Minna
    Member
    Posted 4 years ago #

    Did you try this <?php if ( is_home() and !is_paged() ) { ?> <?php } ?>?

    Or where is it showing where it's not supposed to?

  5. MacGuy22
    Member
    Posted 4 years ago #

    I just tried <?php if ( is_home() and !is_paged() ) { ?> <?php } ?>. It doesn't work for me. The text is stil showing on my pages. It doesn't show up in the archives, but the text shows up everywhere else.

  6. Kafkaesqui
    Moderator
    Posted 4 years ago #

    Try if(empty($_SERVER['QUERY_STRING']))

  7. MacGuy22
    Member
    Posted 4 years ago #

    Where do I put if(empty($_SERVER['QUERY_STRING']))?

  8. Kafkaesqui
    Moderator
    Posted 4 years ago #

    <?php if(empty($_SERVER['QUERY_STRING'])) { ?>

    <?php } ?>

    It replaces the if ( is_home() and !is_paged() )

  9. MacGuy22
    Member
    Posted 4 years ago #

    The <?php if(empty($_SERVER['QUERY_STRING'])) { ?>

    <?php } ?> code does not work. The text is still showing up on my pages.

  10. alphaoide
    Member
    Posted 4 years ago #

    Paste your index.php with the modification suggested above applied, here http://pastebin.com/.

    You might have done it wrongly.

  11. Minna
    Member
    Posted 4 years ago #

    Do you have a separate page template (page.php)? Or are you doing everything with index.php?

  12. MacGuy22
    Member
    Posted 4 years ago #

    I am doing everything with index.php. I do not have a seperate page.php file in my template.

  13. Minna
    Member
    Posted 4 years ago #

    Well... I don't know why the code keeps showing on pages, but what if you added and !is_page() to the list of is functions? I'm running out of ideas

  14. Kafkaesqui
    Moderator
    Posted 4 years ago #

    I'd follow alphaoide's suggestion and post your source at the pastebin so we can take a look.

  15. MacGuy22
    Member
    Posted 4 years ago #

    ok, sorry I didn't see that post from alphaoide.

    EDIT: link to my code is http://pastebin.com/288120

  16. Minna
    Member
    Posted 4 years ago #

    You need to put that intro text between the <?php if(empty($_SERVER['QUERY_STRING'])) { ?> and <?php } ?>.
    So the block of text goes where the word "and" is in the previous sentence :)

  17. Kafkaesqui
    Moderator
    Posted 4 years ago #

    There's nothing between the

    <?php if(empty($_SERVER['QUERY_STRING'])) { ?>

    and the

    <?php } ?>

    What text in your index.php do you want to display only on the home page? I assume it's the welcome message, so surround that with the PHP above. Place the:

    <?php if(empty($_SERVER['QUERY_STRING'])) { ?>

    before the start of your text, and

    <?php } ?>

    just after it ends.

  18. MacGuy22
    Member
    Posted 4 years ago #

    Thank you so much, my problem is solved. That was a really stupid mistake on my part.

  19. Kafkaesqui
    Moderator
    Posted 4 years ago #

    "That was a really stupid mistake on my part."

    Only if you've been programming in PHP for a while. Otherwise it was just a mistake. :)

  20. samdeskin
    Member
    Posted 4 years ago #

    Okay...i am trying to put something on my homepage as well...but I am not sure where to put the code above in the index.php page...please help!
    '<?php if(empty($_SERVER['QUERY_STRING'])) { ?>'

    'fmblog_get_latest(10);'

    '<!-fmblog->'

    '<?php } ?>'

Topic Closed

This topic has been closed to new replies.

About this Topic