WordPress.org

Forums

Spun
Circles to Pages part 2 - navigation (9 posts)

  1. elotroalex
    Member
    Posted 2 years ago #

    Hi Caroline (and all),

    The site is coming along nicely. I'm having tons of fun making the theme go "circles all the way down." I got to the point where I could get my circles in pages that pull posts by categories. You can see how I did that in an earlier post.

    Now I got stumped trying to get the navigation buttons « » in the nav-below class to show. These are useful when you exceed the number of posts allowed in Settings/Reading. You can see them in the home page just fine. I thought the solution would be as easy as adding the spun_content_nav function to my Template page after the content template part. Here's what I have so far:

    <?php
    /*
    Template Name: Projects
    */
    
    get_header();
    ?>
    
    <div id="primary" class="content-area">
      <div id="content" class="site-content" role="main">
    
      <?php
      the_post(); 
    
      $args = array(
    	// Change these category SLUGS to suit your use.
    	'category_name' => 'projects', 
    
      );
    
      $list_of_posts = new WP_Query( $args ); 
    
      while ( $list_of_posts->have_posts() ): $list_of_posts->the_post();
    
      get_template_part( 'content', 'home' );
    
      endwhile;
      ?>
    
    <?php spun_content_nav( 'nav-below' ); ?>
    
    </div><!-- #content .site-content -->
    </div><!-- #primary .content-area -->
    
    <?php get_sidebar(); ?>
    <?php get_footer();

    The page using the template can be found here.

    [scratches his head]

  2. elotroalex
    Member
    Posted 2 years ago #

    I just noticed that the HTML of the page has the nav-below id.

    <nav role="navigation" id="nav-below" class="site-navigation paging-navigation">
    		<h1 class="assistive-text">Post navigation</h1>
    
    	</nav><!-- #nav-below -->
    
    </div><!-- #content .site-content -->
    </div><!-- #primary .content-area -->

    I'm guessing the function is failing to generate the rest of the content for the navigation, no? If that's the case, any ideas why?

  3. elotroalex
    Member
    Posted 2 years ago #

    Hi all,

    I found a tentative solution, which is to simply list all posts in the same page. This means no navigation, as in the home page, so it's not optimal.

    To have a page show all your circles add the following parameter to your $args variable within the array:

    'posts_per_page' => -1

    The end result should look like this:

    $args = array(
    	// Change these category SLUGS to suit your use.
    	'category_name' => 'projects', 'posts_per_page' => -1,
    
      );
  4. Caroline Moore
    Member
    Theme Author

    Posted 2 years ago #

    Post navigation in Spun is hidden until you hover over it (appearing only for small screens/mobile devices). You'll see this when you look at the opacity styles applied to #nav-below in the theme's style.css.

    Content navigation has to be included within The Loop or else its functions won't work, which is what you're seeing with the empty markup.

  5. elotroalex
    Member
    Posted 2 years ago #

    Hi Caroline, thanks for the answer.

    I thought that's what I was doing with the line

    <?php spun_content_nav( 'nav-below' ); ?>

    (see code above)

    What am I doing wrong?

  6. Caroline Moore
    Member
    Theme Author

    Posted 2 years ago #

    It's not currently within The Loop -- you need to include it before the endwhile; portion of the above code.

  7. elotroalex
    Member
    Posted 2 years ago #

    I tried doing that, and it then adds it after every circle (rightly so). I borrowed my approach from your own code (below), where it is outside of the endwhile;

    Am I missing something?

    <?php
    /**
     * The main template file.
     *
     * This is the most generic template file in a WordPress theme
     * and one of the two required files for a theme (the other being style.css).
     * It is used to display a page when nothing more specific matches a query.
     * E.g., it puts together the home page when no home.php file exists.
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package Spun
     * @since Spun 1.0
     */
    
    get_header(); ?>
    
    		<div id="primary" class="content-area">
    			<div id="content" class="site-content" role="main">
    			<?php if ( is_home() && ! is_paged() ) : ?>
    				<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
    			<?php endif; ?>
    			<?php if ( have_posts() ) : ?>
    
    				<?php /* Start the Loop */ ?>
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php
    						/* Include the Post-Format-specific template for the content.
    						 * If you want to overload this in a child theme then include a file
    						 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    						 */
    						get_template_part( 'content', 'home' );
    					?>
    
    				<?php endwhile; ?>
    
    				<?php spun_content_nav( 'nav-below' ); ?>
    
    			<?php elseif ( current_user_can( 'edit_posts' ) ) : ?>
    
    				<?php get_template_part( 'no-results', 'index' ); ?>
    
    			<?php endif; ?>
    
    			</div><!-- #content .site-content -->
    		</div><!-- #primary .content-area -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  8. Caroline Moore
    Member
    Theme Author

    Posted 2 years ago #

    Hmm, you're right, it doesn't have to be in The Loop unless it's single post view.

    I would try looking at the navigation function itself in inc/template-tags.php. You probably need to take the paged query variable into account somehow, since you're using a custom query.

    This thread might have some useful info:
    http://wordpress.org/support/topic/adding-pagination-to-a-wp_query-loop?replies=16

  9. elotroalex
    Member
    Posted 2 years ago #

    Thanks!

    I'll read the thread soon and look at the template-tags.php to see if our answer is there. Stay tuned!

    :)

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic