![]() |
Fatal error: Call to undefined function is_home()
hi looking for some help here!
I'm using this code to display something on the home page only, not on the category, posts, or archives pages. This is the code: <?php if(is_home() && $post==$posts[0] && !is_paged()) { ?> ADVERTISEMENT HERE <?php } ?> But when I use that I get this error: Fatal error: Call to undefined function is_home() Any help is much appreciated thanks! |
yes, you're using a function "is_home()" and "is_page()" in an equasion. I don't think you can do that.
|
Quote:
The problem you have is that the functions are not defined. (You need to have the functions included in the php file). |
You have the code? Pls copy andpaste thx
|
Why would I have your code?
|
Quote:
|
is it near the top of the page? maybe you're using it before the functions are called in
|
Quote:
Code:
<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?> |
Quote:
|
That code is disgusting
|
Quote:
|
is_home() isn't a native php function. It couldn't ever be, and i'm not even going to begin to explain why.
However, At some point, it's probably been written in some script you previously had. Are you defining this function elsewhere in your codebase? If so, you'll need to use include() to pull the file that defines the function into the script you're working with. It's kinda like writing something like: Code:
<? fucking(); ?> Code:
<? function fucking() { echo "do the bartman"; } ?> Code:
<? include('includes/func.fucking.php'); fucking(); ?> Code:
<? function fucking() { echo "do the bartman"; } fucking(); ?> |
PHP Code:
|
Quote:
Code:
<?php |
Quote:
i added it to a current theme, and it worked like a charm. |
Quote:
Do i need to add something in functions.php or something? Im still getting Fatal error: Call to undefined function is_home() |
Quote:
What I don't get is why you need all the other statements. If it is the home page, then when or why would archive, paged, category, tag, or single ever return? Seems odd to me (though I don't use wordpress a lot). |
Now that I think about it, wouldn't
Code:
<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?> [b]Show the ad if: • It's the home page • Or if it's not the archive • Or if it's not paged • Or if it's not a category • Or if it's not a tag • Or if it's not a single.[b] So it would display the ad on any page that wasn't the archive for instance. Because with all the "OR" double pipes, only one of those circumstances needs to be true for the ad to display. |
Quote:
|
Quote:
using that code if i view a category or tag page or full post, it doesnt show the ad. only on the home, not any paged page2,page3, etc. |
Quote:
|
you are an idiot.
|
Quote:
its a wordpress function. |
Quote:
Why not simply use: Code:
<?php if (is_home()) {?> Because using Code:
<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?> Code:
<?php if (is_home()) {?> Code:
<?php if (!is_archive()) {?> Maybe I'm not explaining myself, but I just don't understand the point of having alllll those extra OR statements? |
Quote:
|
Quote:
|
All times are GMT -7. The time now is 03:34 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123