Double conditions in "if" statement pls help
-
I’ve been working on this for 8 hours and it still doesn’t work.
I want to hide part of the post of a specific category but only for users who are not logged in. I’ve tried everything on this forum and on others and I had no choice but to register here and post this. I’ got something so I’m half way of what I want but I don’t know how to do it.
This what I want:
If the unregistered user accesses a post from the Original category, then show a warning message telling him he must register to see that part.
The same part of the post of the rest categories should be shown to unregistered users.
Something like this
if (unregistered and category is Original) then show warning message
else show the postThe problem is I don’t know how to use 2 conditionals.
This is what I have so far.<?php if (is_user_logged_in() && in_category(‘original’)) : ?>
//part to hide//
<?php else :?>
//warning message and registration link//
<?php endif;?>The problem with this is that it does the exact opposite. It shows the message on all posts from all categories when logged out when it should only show it for posts that are in the Original category.
When I’m logged in it shows the message to all posts except to the ones in the Original category when in reality it should not show the message at all.
Can anybody tweak this code and make it right. Thank you so much. Any tip is highly appreciated
- The topic ‘Double conditions in "if" statement pls help’ is closed to new replies.