meereck
Member
Posted 2 months ago #
Hello,
I am writing a plugin, and I want to check whether the home page is being shown.
I tried is_home() function within my plugin but that function doesnt return anything.
Can anybody please tell me how I can check if the home page is displayed?
cheers
M.
Does is_front_page() work?
meereck
Member
Posted 2 months ago #
it doesnt work either.:(
any clues how to find out if the front page is being displayed?
cheers
meereck
Member
Posted 2 months ago #
i did some testing, and wordpress behaves rather weird:
Here is my theme/index.php
get_header(); ?>
<div id="data">
<?php echo "home:". is_home();?>
<?php
if(is_home())
{
query_posts('category_name=Main');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="item">
<h2 class="item"><?php the_title(); ?> (<?php echo the_time("j.n.Y H:i");?>)</h2>
<?php
the_content();?>
</div>
<?php
endwhile; endif;
}
?>
<?php echo "home:". is_home();?>
</div>
<?php get_footer(); ?>
When showing the front page, the first occurence of is_home() returns 1 whereas the second one returns nothing.
Can anybody tell me what I am doing wrong?
thanks
meereck
Member
Posted 2 months ago #
The thing is I want to use is_home function in the footer, and it never works there.