hi all,

I am wondering if someone could give me a quick hand with some php im trying to edit in Wordpress.

Heres the original peice I am trying to edit:

<div class='dateauthor'>
            <small class='capsule'><?php the_time('F jS, Y') ?> by <?php the_author() ?> 
	</small>
        </div>

What I want to do is when "the_author" equals "admin" for the div to be hidden or deleted.

I have added this to make sure that it can find admin

<?php if ($author=="admin"){echo "hello24241";} ?>

and edit here...

<?php $author=the_author() ?>

My question I guess would be is there a statement that would be able to hide/delete the div? Or should I be re-writing this code, like this...

<?php $author = the_author(); ?>
<?PHP if ($author=="admin")?> working
<?php else: ?> [B]\* I get an error on this line *\[/B]
        <div class='dateauthor'>
            <small class='capsule'><?php the_time('F jS, Y') ?> by <?php the_author() ?> 
			</small>
        </div>
<?php endif; ?>

Thanks for any help,

and if you need me to be a little more clear just ask,

tian

It depends on what you're trying to do. If you want that div to never show up, then you can do something like:

<?php if (!$author == "admin") { ?>
<div class='dateauthor'>
...
</div>
<?php } ?>

No need to have the else clause when you aren't really using the if. BTW, I believe you want:

<?php $author = get_the_author(); ?>

else it will just print the author each time you call the_author();

Also, if you want to hide the div, you can just add some CSS and set the class or manually insert style="" to set "display:none;" when your php deems it appropriate.

That help?

-geis

Hey thanks a lot for the replies,

Flash, with the wp_list that is used for the page that displays the authors. I want to hide the info on the actual post/page that is view where it has the author beside the article (but I want to display anybody else besides admin). I have tried the could you suggested in the author_template but won't work. I am assuming this is just for just the author listing page, thanks.


bgeisel:

I might be missing something here, but I want to normally display the following html (this is what is there now):

<div class='dateauthor'>
            <small class='capsule'><?php the_time('F jS, Y') ?> by <?php the_author() ?> 
	</small>
        </div>

But when the author is an admin for the div to be hidden.

I tried this from your code:

<div class='dateauthor'>
            <small class='capsule'><?php the_time('F jS, Y') ?> by <?php $author = the_author() ?> 
			</small> 
        </div>

      <?php if ($author == "admin") { ?>
      <div class='dateauthor'>
      ...
      </div>
      <?php } ?>

But it just creates another div as expected with the periods.

Sorry but thank you for the help

bgeisel:

I might be missing something here, but I want to normally display the following html (this is what is there now):

<div class='dateauthor'>
            <small class='capsule'><?php the_time('F jS, Y') ?> by <?php the_author() ?> 
	</small>
        </div>

But when the author is an admin for the div to be hidden.

I tried this from your code:

<div class='dateauthor'>
            <small class='capsule'><?php the_time('F jS, Y') ?> by <?php $author = the_author() ?> 
			</small> 
        </div>

      <?php if ($author == "admin") { ?>
      <div class='dateauthor'>
      ...
      </div>
      <?php } ?>

But it just creates another div as expected with the periods.

Sorry but thank you for the help

Hey cjay,

You're supposed to replace your code with what I provided. The 3 dots are an ellipsis and it means that something is being omitted. In this case you were supposed to put the rest of your HTML in there ;-)

The `if ($admin != get_the_author())` should only display the <div> ... </div> when the author is not equal to admin. (where "..." is whatever is inside the div.)

I think that makes the whole thing look something like this:

<?php 
    $author = get_the_author();
    if ($author != "admin") {
    // Only display this div if our author is not "admin"
?>
<div class='dateauthor'>
    <small class='capsule'><?php the_time('F jS, Y') ?> by <?php the_author() ?>
    </small> 
</div>
<?php } ?>

Little better?

-geis

Ok I didn't realize that...whoops! Anyway I believe bgeisel meant for you to get the author name first and replace the ... with the_author(). So something like this:

<?php
if (!get_the_author()=="admin")
{
echo "        <div class='dateauthor'>";
echo "            <small class='capsule'>".the_time('F jS, Y')." by ".the_author(); 
echo "			</small>";
echo "        </div>";
}
?>

Ahh... lol

Opps, I didn't realize that I thought it was odd "..." my bad, but now I know.

Anywayz I put your code in and it worked wonderfully.

Thanks a lot flash and bgeisel

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.