Home Website News Articles Standard Post

Standard Post

WordPress Code to Display Content Only on Homepage After Setting a Static Page as Homepage

Most people's websites only display friend links on the homepage, not on inner pages. Normally, we can use <?php if (is_home() && !is_paged()) : ?> to check if it's the homepage. However, if a static page is set as the homepage, this check will fail. I...

Posted on December 23, 2019 About 1 minute read

Most websites only display blogroll links on the homepage, not on inner pages. Normally, we can use<?php if (is_home ()&&!is_paged() ) : ?>to check if it's the homepage. However, if a static page is set as the homepage, this check will fail. We can use the following method to determine it.

<?php if ( is_front_page() ) { ?>
要显示的内容或者代码
<?php } ?>

The normal homepage call code is:

<?php if (is_home ()&&!is_paged() ) : ?>
要显示的内容或者代码
<?php endif; ?>

You can see two code checks: one is is_front_page, and the other is is_home.

When we set a static page as the homepage in the backend, we can only use the is_front_page function to determine if it's the homepage.

References

2.3/5 - (3 votes)
Previous How to Build a Website After Getting a Server Continue reading content around the same timeline. Next 3 Methods to Exclude Specific Category Articles from Displaying on the WordPress Homepage View the next related tutorial or experience.

AI Website Building Assistant

🤖
Hello! I am the Naibabiji AI Assistant. How can I help you?
Quick Consultation: