Fun with PHP

I’ve been trying to figure out something, but I don’t really know PHP, so I’m having a bit of trouble with it. See, Wordpress innately doesn’t show private posts on the front page; you can only see them from within the admin panel. I just don’t really like that. Livejournal will display private posts if you’re logged in as the author, and I’m pretty sure this is doable in Wordpress too, I just need to figure out the code for it. Actually, what I want to do is specify a category and only display posts in that category if the user is currently logged in. It seems like that should only need a simple
if (!in_category(ID#) || $user-logged-in) check before the display code, but I’m not 100% confident in my programming logic skills anymore, plus I don’t know what the PHP syntax for such a statement, followed by a block of html code, would be. Plus I don’t know where to find $user-logged-in (since that’s a made-up variable). If said statement returns false, it’d need to skip the code that displays the post, and move on to the next iteration of the while loop. Does that even make sense? If you know or have any idea where a good resource might be (I’ve found a few references over at the WP forums, but they’re very old and not exactly what I’m looking for), please let me know~

Update: thanks to a look through some PHP books that sort of crystalized how PHP and HTML code work together, and those useful comments of cruinh’s, I’ve got this figured out. Hooray~ ;)

4 Comments »

RSS feed for comments on this post.

Speak your mind~

Comment moderation for first-time posters is used on this site, so don't be alarmed if your comment doesn't show up immediately. The admin will review comments from any new visitors as soon as possible.

Go to Gravatar.com to get a nifty global avatar.

The following html tags are available:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>