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.
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
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.
Did you try this <?php if ( is_home() and !is_paged() ) { ?> <?php } ?>?
Or where is it showing where it's not supposed to?
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.
Try if(empty($_SERVER['QUERY_STRING']))
MacGuy22
Member
Posted 4 years ago #
Where do I put if(empty($_SERVER['QUERY_STRING']))?
<?php if(empty($_SERVER['QUERY_STRING'])) { ?>
<?php } ?>
It replaces the if ( is_home() and !is_paged() )
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.
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.
Do you have a separate page template (page.php)? Or are you doing everything with index.php?
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.
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
I'd follow alphaoide's suggestion and post your source at the pastebin so we can take a look.
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
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 :)
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.
MacGuy22
Member
Posted 4 years ago #
Thank you so much, my problem is solved. That was a really stupid mistake on my part.
"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. :)
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 } ?>'