Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a options page and i use this code.

I want this, I add author id on sometext field (e.g 3,2,5,11 ) and my author.php redirect custom author page.

My author.php

<?php $post = $wp_query->post;
$options = get_option('sample_theme_options');
 if (is_author( array($options['sometext']) ) ) {
 include(TEMPLATEPATH . '/brand.php');
}
else { include (TEMPLATEPATH . '/customauthor.php');
}
?>

Im adding Some Text field number like this 3,2,5,11

 <?php echo  $options['sometext']; ?>

And code Output: 3,2,5,11

But my author.php not working good. Just first id working other id not working.

How can i fix it?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You can do the following:

<?php

$post = $wp_query->post;
$options = get_option( 'sample_theme_options' );
$authors = explode( ',', $options['sometext'] );

if ( is_author( $authors ) ) {
    include ( TEMPLATEPATH . '/brand.php' );
} else {
    include ( TEMPLATEPATH . '/customauthor.php' );
}

?>

This way, you're always sure that $authors contains an array.

share|improve this answer
    
It worked. Thanks –  Genxer Feb 7 '13 at 17:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.