Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Non static home page with static content WordPress

  • SOLVED

Going to try and explain this as best as I can.

my index.php contains static text like this:

-------------------

static text

loop to show latest 10 blog posts

static text

older entries link

------------------

when I click the older entries link the same static text shows and the loop produces the older posts. the url structure is: url.com/page/2


I have tried the following so that the static text does not show up on /page/2

1. tried wrapping the text using is_home() and is is_front_page() conditional tags without setting static page in settings/reading (in wp-admin)

2. same as above, but created a page called home and set it to the static page. This caused the loop to not work.

the loop I'm using:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to
<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

<?php the_content('Read the rest of this entry &raquo;'); ?>
<?php edit_post_link('Edit', '', ' '); ?>
<br />
<hr style="color:#0065D7;" />
<br />
<?php endwhile; ?>

<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php endif; ?>


3. tried setting a blog posts page in settings/reading without and with a static page set.

What I want is that static text to not display on the next pages as it might be interpreted as duplicate content.

Answers (5)

2011-12-28

Arnav Joy answers:

do not make any front page or any thing else

try this in your index.php

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

echo $paged;

this will give you the page no. you are currently in like 1,2,....

you can use it

<?php if($paged <= 1) { ?>

<!-- static content -->

<?php } ?>

2011-12-28

Julio Potier answers:

Hello, try this conditionnal tag :

<?php
$paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : false;
if ( $paged === false )
{
// This is not a paginated page (or it's simply the first page of a paginated page/post)

}
else
{
// This is a paginated page.

}
?>


See you soon

edit : Price is $25, if my answer is correct, i deserve the full price, if you want to thank other good answer (other cloned answers) please upgrade the price.

2011-12-28

Romel Apuya answers:

have you tried adding those conditions on content-page.php?
or page.php?


Romel Apuya comments:

if you want i can take a look at the theme that you are using.
can you provide ftp details via PM.

thanks..

2011-12-28

Navjot Singh answers:

Try this code in your existing index.php:

<?php
$paged = $wp_query->get( 'paged' );

if ( ! $paged || $paged < 2 )
{ ?>
static text
<?php }
?>

2011-12-28

Thierry Pigot answers:

Hi,

For the home page, copy the <strong>index.php</strong> file and rename this file as <strong>front-page.php</strong>.

Now, in the <strong>index.php</strong> file remove the static text.

;-)

Thierry