Support » Themes and Templates » the_author() won't display

  • Hey all,

    I’ve got a little problem. I’m working on a wordpress theme right now and we made something very cool. When you press on a image the post will load at the top of the page. This is a very nice trick but it has one problem which I can’t solve right now. I can’t manage to display the user.

    Below is the code:

    add_action( 'wp_ajax_nopriv_myajax-submit', 'ajax_project_load' );
    add_action( 'wp_ajax_myajax-submit', 'ajax_project_load' );
    
    function ajax_project_load() {
    
    	$the_slug = $_POST['slug'];
    	$args=array(
    	  'name' => $the_slug,
    	  'post_type' == 'post',
    	  'post_status' => 'publish',
    	  'showposts' => 1,
    	  'ignore_sticky_posts' => 1
    	);
    
    	$the_author = get_the_author( $post );
    
    	$my_posts = get_posts($args);
    	if( $my_posts ) :
    
    		global $post;
    		$post = $my_posts[0];    	
    
        	// generate the response
        	$response = json_encode( "Success" );
    
        	// response output
        	header( "Content-Type: application/json" );
    		?>
    
    		<div id="ajax-project-<?php the_ID(); ?>" <?php post_class('project main ajax clearfix'); ?> >
    
    			<div class="projectHeader">
    				<h1><?php the_title(); ?></h1>
    
    				<div class="projectNav clearfix">
    					<div class="closeBtn">
    						<a href="#">Close Project</a>
    					</div>	<div class="naam">HERE THE NAME
    					<?php echo $the_author; ?>
    					</div>	<div class="tijd">
    						<?php the_time('j F') ?>
    					</div>
    				</div>
    			</div>
    
    				<?php echo wpautop(do_shortcode(add_video_containers($post->post_content))); ?>	
    
    		</div>
    		<?php $slideshow_delay = of_get_option('jo_slideshow_delay'); ?>
    		<?php $slideshow_delay = ($slideshow_delay != "") ? $slideshow_delay : '6'; ?>
    		<script type="text/javascript">
    		//<![CDATA[
    			waitForMedia("<?php echo $the_slug; ?>", <?php echo $slideshow_delay; ?>);
    			lightboxInit();
    			//]]>
    		</script>			
    
    	<?php endif; ?>	
    
    <?php
        exit;
    }

    I have tried many things, but I do not understand the code fully. Maybe you know a solution.

    I have been givven the code by guy – he told me it displayed first projects without authors. But he wanted it to show posts with authors.

    Thanks in advance,
    Robin

  • The topic ‘the_author() won't display’ is closed to new replies.