J B
Forum Replies Created
-
Forum: Everything else WordPress
In reply to: if_new-visitor-to-website?? how to set PHP to check?oops I saw one of my own errors in the code but the problem remains. are you suggesting I have to use codeigniter with wordpress? isn’t it a seperate platform?
How can I achieve this in wordpress without codeigniter. The cookiehelper doesn’t work.
Forum: Everything else WordPress
In reply to: if_new-visitor-to-website?? how to set PHP to check?This is a code I wrote to test it to say “hello”, but it says:
Fatal error: Call to undefined function get_cookie()<?php if (!get_cookie('new_visitor')) {?> hello <?php } ?> // cookie not set, first visit // create cookie to avoid hitting this case again $cookie = array( 'name' => 'new_visitor', 'value' => 'Yes', 'expire' => time()+86500, 'domain' => 'mysite.com', 'path' => '/', 'prefix' => '', ); set_cookie($cookie); } ?>
How can I fix it?
Forum: Everything else WordPress
In reply to: if_new-visitor-to-website?? how to set PHP to check?Basically if I put my code I only want to activate once, like my welcome message, in the spot mentioned above it would work only once, and then the cookie is planted right? and since it is activated only if it can NOT get_cookie then it wouldn’t activate again right?
just checking. thanks again.
Forum: Everything else WordPress
In reply to: if_new-visitor-to-website?? how to set PHP to check?Not sure what to do. Correct me if I’m wrong.
if (!get_cookie(‘new_visitor’)) { —INSERTING code here would work BEFORE cookie planted??—-
// cookie not set, first visit// create cookie to avoid hitting this case again
$cookie = array(
‘name’ => ‘new_visitor’,
‘value’ => ‘Yes’,
‘expire’ => time()+86500,
‘domain’ => ‘.my-domain.com’,
‘path’ => ‘/’,
‘prefix’ => ”,
);
set_cookie($cookie);
}Thanks for the help.
You are my hero! Seriously. Thanks a million. Problem finally solved.
Forum: Hacks
In reply to: Randomized, but static, output on every page? Possible? How?The goal is that every user who sees Page A sees one quote,
And every user who sees Page B sees a different quote.Thus randomized, but not changing (neither on refresh or per user).
Any ideas?Forum: Hacks
In reply to: Randomized, but static, output on every page? Possible? How?I found one solution, by adding
srand(floor(time() / (60*60*24)));
before the rand it stays the same for 24 hours for example (and I guess I can set it to a super high time to avoid repeating).HOWEVER, if put in the sidebar or header it outputs the same result for ALL pages. Is there any way I can put it in the header and have it show a different result for EACH page? I suspect I will need to use wordpress code for it (adding it into the loop).
Forum: Hacks
In reply to: Randomized, but static, output on every page? Possible? How?I have no idea how I would modify that or how it works.
I thought there might be some wordpress related solution or php solution such as the one below
<? //Chooses a random number $num = Rand (1,6); //Based on the random number, gives a quote switch ($num) { case 1: echo "Time is money"; break; case 2: echo "An apple a day keeps the doctor away"; break; case 3: echo "Elmo loves dorthy"; break; case 4: echo "Off to see the wizard"; break; case 5: echo "Tomorrow is another day"; break; case 6: echo "PHP is cool!"; } ?>
But it always changes on refresh. I want it to NOT change on refresh. Is this possible?
Oh nevermind, I got it working.
Forum: Fixing WordPress
In reply to: How do I customize template via “$post_author” variable???So how would I use that?
If I put, for example:
<?php
$author = get_query_var(‘author’);
if ($author = ‘admin’) {
echo ‘hello’;
}
?>It says hello on all posts not just the admin’s. How can I make it specifically show that hello (or whatever code I want) on ONLY those posts done by a specific author?
Forum: Fixing WordPress
In reply to: How do I customize template via “$post_author” variable???Why doesn’t that code work? What code would work?
I keep trying variations and different things with no success. All I want is to be able to have a string check who is the author of a post, and if it is Joe, then display Joe’s image on all of Joe’s posts, and if it is Sally, Sally’s image on all of Sally’s posts.
Is this impossible with wordpress? Why? Is there a way to create a variable specific to each author? That would allow me to accomplish this.
Forum: Fixing WordPress
In reply to: How do I customize template via “$post_author” variable???NO, NO, NO, you misunderstand!!! Didn’t you read what my goal is??
I don’t want it to just display their name (as “the_author”) does. I don’t want it to “check” if there IS an author.
What I want is for it to check WHO IS the author, and if it is Joe, for example, then it would display “Joe’s image” in the header. If it is Sally, then Sally’s image. Simple enough.
<?php if ($post_author = ‘admin’) {
echo ‘joes image here’;
}
?>Problem is it doesn’t appear at all in the header.php with that code, and if it’s on the single.php it always appears regardless of the author. I just want to fix that please.
Forum: Fixing WordPress
In reply to: How do I customize template via “$post_author” variable???Well that’s weird, I tried that but it didn’t work.
<?php if (is_author(‘admin’) ) {
echo ‘hello’;
}
?>I put that in the template, in header.php and even in the posts themselves with single.php and “hello” didn’t show up in either. What am I doing wrong? I get the author part now I think, but can you give me the full code? Or does it not work with WordPress MU? Thanks for your time.