Support » Themes and Templates » A little help with a page template

  • Hi!

    Just created an authors list page template following some web tutorial and mixing it with the style of my theme, but i’m not reaching one thing, and i’m sure it is really easy.

    Here is the code:

    <?php
    /*
    Template Name: Autores
    */
    
    // Get all users order by amount of posts
    $allUsers = get_users('orderby=post_count&order=DESC');
    
    $users = array( ) ;
    
    // Remove subscribers from the list as they won't write any articles
    foreach($allUsers as $currentUser)
    {
    	if(!in_array( 'subscriber', $currentUser->roles ))
    	{
    		$users[] = $currentUser;
    	}
    }
    
    ?>
    
    <?php get_header(); ?>
    
    <div class="vw-page-wrapper clearfix <?php vw_the_sidebar_position_class(); ?>">
    	<div class="container">
    		<div class="row">
    <div class="pagina-autores">
    	<?php
    
    		foreach($users as $user)
    		{
    			?>
    
    			<div class="pagina-autores-info" <?php vw_itemprop('author'); vw_itemtype('Person'); ?>>
    
    	<?php if ( ! empty( $instance['title'] ) ) : ?>
    	<h3 class="vw-widget-author-title">
    		<span><?php echo $instance['title']; ?></span>
    	</h3>
    	<?php endif; ?>
    
    	<?php echo vw_the_author_avatar( $user, VW_CONST_AVATAR_SIZE_LARGE ); ?>
    
    	<h4 class="vw-widget-author-name" <?php vw_itemprop('name'); ?>>
    		<?php echo nl2br( $user->display_name ); ?>
    	</h4>
    
    	<div class="vw-widget-author-bio" <?php vw_itemprop('description'); ?>>
    		<?php echo nl2br( $user->user_description ); ?>
    	</div>
    
    	<div class="vw-author-socials">
    		<?php vw_the_user_social_links( $user ); ?>
    	</div>
    
    		</div>
    
    			<?php
    		}
    	?>
    
    </div>
    
    		<?php get_sidebar(); ?>
    
    		</div>
    	</div>
    </div>
    <?php get_footer(); ?>

    I want 2 things that i’m not being able to reach:

    – Exclude the main user from this list
    – Put the sidebar in its place. Now it is showing below the content, i’ve tried to chage the get_sidebar a lot of places, but i can’t make it appear on its place

    Anyone have a clue? I’m not a code writer, just a copy / paste one, so any step by step explanation will be really apreciated!

    Thanks a lot

Viewing 2 replies - 1 through 2 (of 2 total)
  • @hashnse,

    1) I’m not a developer, but from the documentation, it seems get_users() has the option to exclude specific users by ID. See: https://codex.wordpress.org/Function_Reference/get_users

    2) Without a link to your site or even mention of the theme you’re using, it’s difficult to know exactly what’s going on here. Try moving the <?php get_sidebar(); ?> line down one </div> at a time (and test each time) to see what happens.

    Hi George, thanks a lot

    the theme i’m using is called Sprout

    I’ve tried to move the get_sidebar all the </div> up and down, sometimes nothing happens, sometimes it gets messy inside the info of the container…

    Abouth the get_users exclude, i’ve tried but i dont know how to set it properly, because i’m not getting it to work… the user id is 1, but i have tried a pair of mod to the line, and nothing happened

    thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘A little help with a page template’ is closed to new replies.