WordPress.org

Ready to get started?Download WordPress

Forums

How to add code to top of author page via plugin? (1 post)

  1. Daniel McClure
    Member
    Posted 2 years ago #

    Hey There,

    I'm currently coding a plugin that adds an author box to the top of the author archives page and a link below any other archives pages. I have been attaching my function to loop_start however this seems to also add the code inside my recent posts widget on the sidebar.

    function custom_author_box_plugin() {
    	global $post;
    
    	$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
    
    	if (is_author()) {
    		?>
    		<div>The Author Box code here</div>
    		<?php
    	}
    	else if (is_archive() && (!is_author())) {
    		?>
    		<div>Code for standard archives here.</div>
    		<?php
            }
    }
    add_action('loop_start' , 'custom_author_box_plugin');

    Can anyone guide me in the right direction for only showing the code in the relevant place rather than what I presume is another loop on the page inside a widget?

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by Daniel McClure
  • This topic is not resolved
  • WordPress version: 3.3.1