• hey everyone! Running into a block here and need some help. I’m trying to set up the author.php page in twenty twelve (in a child theme) to handle a conditional statement where when you click one of two buttons on posts, etc you either get the authors bio and posts or you get a contact form that goes directly to them.

    I have both the parts working and displaying on author.php but can not figure out how to condition the link from say the contributors page. I haven’t found any of the WP conditions that would work for such a thing.

    my apologies, my php is so-so but I do understand the set up of WP.

Viewing 1 replies (of 1 total)
  • Thread Starter scifizoe

    (@scifizoe)

    Here’s the full author.php file with the two blocks I want conditioned to only show when you click the correct link to this page.

    <?php
    /**
     * The template for displaying Author Archive pages.
     *
     * Used to display archive-type pages for posts by an author.
     *
     * Learn more: https://codex.www.ads-software.com/Template_Hierarchy
     *
     * @package WordPress
     * @subpackage Boston_Financial
     * @since Boston Financial 1.0
     */
    
    get_header(); ?>
    
    	<section id="primary" class="site-content">
    		<div id="content" role="main">
    
    		<?php if ( have_posts() ) : ?>
    
    			<?php
    				/* Queue the first post, that way we know
    				 * what author we're dealing with (if that is the case).
    				 *
    				 * We reset this later so we can run the loop
    				 * properly with a call to rewind_posts().
    				 */
    				the_post();
    			?>
    
    			<header class="archive-header">
    				<h1 class="archive-title"><?php printf( __( 'Author Archives: %s', 'bostonfinancial' ), '<span class="vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( "ID" ) ) ) . '" title="' . esc_attr( get_the_author() ) . '" rel="me">' . get_the_author() . '</a></span>' ); ?></h1>
    			</header><!-- .archive-header -->
    
    			<?php
    				/* Since we called the_post() above, we need to
    				 * rewind the loop back to the beginning that way
    				 * we can run the loop properly, in full.
    				 */
    				rewind_posts();
    			?>
    
    			<?php bostonfinancial_content_nav( 'nav-above' ); ?>
    
    			<?php
    			// If a user has filled out their description, show a bio on their entries.
    			if ( get_the_author_meta( 'description' ) ) : ?>
    			<div class="author-info">
    				<div class="author-avatar">
    					<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'bostonfinancial_author_bio_avatar_size', 60 ) ); ?>
    				</div><!-- .author-avatar -->				
    
    				<div class="author-link">
    					<a class="btnMain" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
    						Contact <?php echo the_author_meta('first_name'); ?> »
    					</a>
    
    				</div><!-- .author-link	-->
    
    				<div class="author-description">
    					<h2><?php printf( __( 'About %s', 'bostonfinancial' ), get_the_author() ); ?></h2>
    					<p><?php the_author_meta( 'description' ); ?></p>
    				</div><!-- .author-description	-->
    			</div><!-- .author-info -->
    			<?php endif; ?>
    
    			<!-- this only to show when clicking to contact author -->
    			<?php echo do_shortcode("[contact-form-7 id='781' 'Contact Author']"); ?> 
    
    			<!-- this only to show when clicking view articles or bio info -->
    			<?php /* Start the Loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php bostonfinancial_entry_meta(); ?>
    				<h2 class="entry-title"><?php the_title(); ?></h2>
    				<?php abyline_authordate(); ?>
    				<?php the_excerpt(); ?>
    
    			<?php endwhile; ?>
    
    			<?php bostonfinancial_content_nav( 'nav-below' ); ?>
    
    		<?php else : ?>
    			<?php get_template_part( 'content', 'none' ); ?>
    		<?php endif; ?>
    
    		</div><!-- #content -->
    	</section><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Conditional on Author Page’ is closed to new replies.