GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Fatal error: Call to undefined function is_home() (https://gfy.com/showthread.php?t=1011204)

bloggerz 02-20-2011 05:44 PM

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!

BittieBucks Eric 02-20-2011 06:26 PM

yes, you're using a function "is_home()" and "is_page()" in an equasion. I don't think you can do that.

HarryMuff 02-20-2011 07:08 PM

Quote:

Originally Posted by BittieBucks Eric (Post 17929267)
yes, you're using a function "is_home()" and "is_page()" in an equasion. I don't think you can do that.

Of course you can, the condition statement expects those functions to return a boolean.

The problem you have is that the functions are not defined. (You need to have the functions included in the php file).

bloggerz 02-20-2011 07:11 PM

You have the code? Pls copy andpaste thx

HarryMuff 02-20-2011 07:13 PM

Why would I have your code?

brassmonkey 02-20-2011 07:40 PM

Quote:

Originally Posted by HarryMuff (Post 17929339)
Why would I have your code?

:1orglaugh

FlexxAeon 02-20-2011 07:40 PM

is it near the top of the page? maybe you're using it before the functions are called in

fris 02-20-2011 08:52 PM

Quote:

Originally Posted by bloggerz (Post 17929234)
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!


Code:

<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?>

ad here.

<?php } ?>

this should do it.

martinsc 02-20-2011 09:17 PM

Quote:

Originally Posted by fris (Post 17929460)
Code:

<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?>

ad here.

<?php } ?>

this should do it.

a true ninja :thumbsup

HarryMuff 02-20-2011 10:15 PM

That code is disgusting

grumpy 02-21-2011 01:32 AM

Quote:

Originally Posted by fris (Post 17929460)
Code:

<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?>

ad here.

<?php } ?>

this should do it.

wont solve : function not found.

mlove 02-21-2011 02:32 AM

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(); ?>
This will not work on it's own, but if you have your fucking() function defined in a file like includes/func.fucking.php:

Code:

<? function fucking() { echo "do the bartman"; } ?>
Then you'll be able to use that function.:

Code:

<? include('includes/func.fucking.php'); fucking(); ?>
and then your code would work. But to save on execution time (opening multiple files takes longer), you could do:

Code:

<?  function fucking() { echo "do the bartman"; } fucking(); ?>

Danmixz 02-21-2011 02:49 AM

PHP Code:

<?php
$homepage 
"/";
$currentpage $_SERVER['REQUEST_URI'];
if(
$homepage==$currentpage) {
echo 
'Adcode here' ;
}
?>


Zyber 02-21-2011 05:37 AM

Quote:

Originally Posted by Danmixz (Post 17929840)
PHP Code:

<?php
$homepage 
"/";
$currentpage $_SERVER['REQUEST_URI'];
if(
$homepage==$currentpage) {
echo 
'Adcode here' ;
}
?>


Why create unnecessary variables - when less can do it?

Code:

<?php
if($_SERVER['REQUEST_URI'] == '/') {
 echo 'Adcode here';
}
?>


fris 02-21-2011 08:47 AM

Quote:

Originally Posted by grumpy (Post 17929784)
wont solve : function not found.

where are you using the code?

i added it to a current theme, and it worked like a charm.

bloggerz 02-21-2011 08:08 PM

Quote:

Originally Posted by fris (Post 17929460)
Code:

<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?>

ad here.

<?php } ?>

this should do it.


Do i need to add something in functions.php or something?
Im still getting Fatal error: Call to undefined function is_home()

potter 02-21-2011 09:35 PM

Quote:

Originally Posted by fris (Post 17929460)
Code:

<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?>

ad here.

<?php } ?>

this should do it.

It looks like he wants AND statements, not OR statements?

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).

potter 02-21-2011 09:42 PM

Now that I think about it, wouldn't

Code:

<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?>

ad here.

<?php } ?>

Return the ad on a lot more pages than the home page? You're code is basically saying...

[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.

fris 02-21-2011 10:14 PM

Quote:

Originally Posted by bloggerz (Post 17931915)
Do i need to add something in functions.php or something?
Im still getting Fatal error: Call to undefined function is_home()

where are you adding is_home to?

fris 02-21-2011 10:16 PM

Quote:

Originally Posted by potter (Post 17932098)
Now that I think about it, wouldn't

Code:

<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?>

ad here.

<?php } ?>

Return the ad on a lot more pages than the home page? You're code is basically saying...

[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.

it will only show on the front page.

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.

bloggerz 02-22-2011 12:22 AM

Quote:

Originally Posted by fris (Post 17932155)
where are you adding is_home to?

An external php file and im calling it through php include

mlove 02-22-2011 03:06 AM

you are an idiot.

fris 02-22-2011 06:20 AM

Quote:

Originally Posted by bloggerz (Post 17932363)
An external php file and im calling it through php include

well of course it wont work then ;)

its a wordpress function.

potter 02-22-2011 08:07 AM

Quote:

Originally Posted by fris (Post 17932156)
it will only show on the front page.

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.

Well, it's not-category, and not-paged. My point was

Why not simply use:

Code:

<?php if (is_home()) {?>

ad here.

<?php } ?>

??

Because using

Code:

<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?>

ad here.

<?php } ?>

Is exactly the same as putting:

Code:

<?php if (is_home()) {?>

ad here.

<?php } ?>

and
Code:

<?php if (!is_archive()) {?>

ad here.

<?php } ?>

On the same page. So not only will it show up on the home page, but it would want to be shown on any page that ISN'T an archive page.

Maybe I'm not explaining myself, but I just don't understand the point of having alllll those extra OR statements?

fris 02-22-2011 09:45 AM

Quote:

Originally Posted by potter (Post 17933003)
Well, it's not-category, and not-paged. My point was

Why not simply use:

Code:

<?php if (is_home()) {?>

ad here.

<?php } ?>

??

Because using

Code:

<?php if (is_home() || !is_archive() || !is_paged() || !is_category() || !is_tag() || !is_single()) {?>

ad here.

<?php } ?>

Is exactly the same as putting:

Code:

<?php if (is_home()) {?>

ad here.

<?php } ?>

and
Code:

<?php if (!is_archive()) {?>

ad here.

<?php } ?>

On the same page. So not only will it show up on the home page, but it would want to be shown on any page that ISN'T an archive page.

Maybe I'm not explaining myself, but I just don't understand the point of having alllll those extra OR statements?

ya you would still need to have !is_paged() though, cause home is considered page2 page3 of the index

potter 02-22-2011 10:19 AM

Quote:

Originally Posted by fris (Post 17933247)
ya you would still need to have !is_paged() though, cause home is considered page2 page3 of the index

weird... I suppose it'll all make sense if I ever use wordpress again and see the code and the way the system functions.


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