0

I am using in a wordpress theme, the Redux Framework, to manage the general options, and the ACF for additional options in the posts.

Both in the options panel and in the post fields, you have the option to disable and enable the name of the author of the post.

These are the variables and their values, which I call to show or not the name of the author

On the panel: $opt_panel_author values: true / false

On custom fields $opt_field_author values: inherit / yes / no

Calling on the theme like this:

<?php if ($opt_panel_author == true && $opt_field_author) { ?>
    <span class = "post-meta-author"> By: John Doe </ span>
<?php } ?>

It works to some extent.

What I need now is:

1st - When the option in Panel is true and that of Custom Field isinherit show the author's name.

2nd - When the panel option is false and the Custom Field isyes show the author's name.

3rd - When the panel option is true and Custom Field isno do not show the author's name.

4rd - When the Options Panel and Custom Fields are disabled. Show the name of the author.

2
  • So if I'm understanding this correctly, the $opt_field_author is a simple string scalar type? If so, you will need to test like this: <?php if ($opt_panel_author == true && $opt_field_author == 'yes') { ?> Commented Mar 22, 2018 at 16:46
  • 1
    @ShaunBebbers Yeah, like that. Commented Mar 22, 2018 at 16:51

1 Answer 1

2

Something like this?

<?php if (
           ($opt_panel_author && $opt_field_author == 'inherit') || 
           (!$opt_panel_author && $opt_field_author == 'yes') || 
           (!$opt_panel_author && $opt_field_author == 'no')
         ) { ?>

<span class = "post-meta-author"> By: John Doe </ span>

<?php } ?>
Sign up to request clarification or add additional context in comments.

4 Comments

Not exactly. In $ opt_panel_author there are only two values ` true` and false in` $ opt_field_author` three values, yes, no, and inherit
That's whats been tested.. $opt_panel_author it's the same that $opt_panel_author == true and !$opt_panel_author it's the same that $opt_panel_author == false
you also have to remember that test 3 is basically irrelevant.
@DioneiMiodutzki Okay, I made a mess here, it works. I would like that when the plugin is disabled. Show the author.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.