Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Hakkelaar

    (@hakkelaar)

    Ok, Thanks!

    I will mark this thread as resolved in the sense that my question is theme-dependent.

    Thread Starter Hakkelaar

    (@hakkelaar)

    I understand in what way you are trying to help me.

    I asked about the TwentySixteen code because I want to learn more about WordPress and thought that I could better start with WordPress’ it’s own themes for learning.

    Thread Starter Hakkelaar

    (@hakkelaar)

    This is the archive.php from TwentySixteen.

    Can you point out the distinction-code between tag-pages and category-pages in this file?

    get_header(); ?>
    
    	<div id="primary" class="content-area">
    		<main id="main" class="site-main" role="main">
    
    		<?php if ( have_posts() ) : ?>
    
    			<header class="page-header">
    				<?php
    					the_archive_title( '<h1 class="page-title">', '</h1>' );
    					the_archive_description( '<div class="taxonomy-description">', '</div>' );
    				?>
    			</header><!-- .page-header -->
    
    			<?php
    			// Start the Loop.
    			while ( have_posts() ) : the_post();
    
    				/*
    				 * Include the Post-Format-specific template for the content.
    				 * If you want to override 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( 'template-parts/content', get_post_format() );
    
    			// End the loop.
    			endwhile;
    
    			// Previous/next page navigation.
    			the_posts_pagination( array(
    				'prev_text'          => __( 'Previous page', 'twentysixteen' ),
    				'next_text'          => __( 'Next page', 'twentysixteen' ),
    				'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',
    			) );
    
    		// If no content, include the "No posts found" template.
    		else :
    			get_template_part( 'template-parts/content', 'none' );
    
    		endif;
    		?>
    
    		</main><!-- .site-main -->
    	</div><!-- .content-area -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    Thread Starter Hakkelaar

    (@hakkelaar)

    Dear James,

    Thanks for your quick response!

    The name of the theme is Lovecraft, but I also see this in TwentySixteen.

    I really can’t tell where the code is that deals with tags, and the code that deals with categories in this archive.php:

    <?php get_header(); ?>
    
    <div class="wrapper section">
    
    	<div class="section-inner">
    
    		<div class="content">
    
    			<div class="page-title">
    
    				<div class="section-inner">
    
    					<h4><?php if ( is_day() ) : ?>
    						<?php printf( __( 'Date: %s', 'lovecraft' ), '' . get_the_date( get_option('date_format') ) . '' ); ?>
    					<?php elseif ( is_month() ) : ?>
    						<?php printf( __( 'Month: %s', 'lovecraft' ), '' . get_the_date('F Y') . '' ); ?>
    					<?php elseif ( is_year() ) : ?>
    						<?php printf( __( 'Year: %s', 'lovecraft' ), '' . get_the_date( 'Y' ) . '' ); ?>
    					<?php elseif ( is_category() ) : ?>
    						<?php printf( __( 'Category: %s', 'lovecraft' ), '' . single_cat_title( '', false ) . '' ); ?>
    					<?php elseif ( is_tag() ) : ?>
    						<?php printf( __( 'Tag: %s', 'lovecraft' ), '' . single_tag_title( '', false ) . '' ); ?>
    					<?php elseif ( is_author() ) : ?>
    						<?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?>
    						<?php printf( __( 'Author: %s', 'lovecraft' ), $curauth->display_name ); ?>
    					<?php else : ?>
    						<?php _e( 'Archive', 'lovecraft' ); ?>
    					<?php endif; ?>
    
    					<?php
    					$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    					if ( "1" < $wp_query->max_num_pages ) : ?>
    
    						<span><?php printf( __('(Page %s of %s)', 'lovecraft'), $paged, $wp_query->max_num_pages ); ?></span>
    
    						<div class="clear"></div>
    
    					<?php endif; ?></h4>
    
    				</div> <!-- /section-inner -->
    
    			</div> <!-- /page-title -->
    
    			<?php if ( have_posts() ) : ?>
    
    				<?php rewind_posts(); ?>
    
    				<div class="posts" id="posts">
    
    					<?php while ( have_posts() ) : the_post(); ?>
    
    						<?php get_template_part( 'content', get_post_format() ); ?>
    
    					<?php endwhile; ?>
    
    				</div> <!-- /posts -->
    
    				<?php lovecraft_archive_navigation(); ?>
    
    			<?php endif; ?>
    
    		</div> <!-- /content -->
    
    		<?php get_sidebar(); ?>
    
    		<div class="clear"></div>
    
    	</div> <!-- /section-inner -->
    
    </div> <!-- /wrapper.section -->
    
    <?php get_footer(); ?>
    Thread Starter Hakkelaar

    (@hakkelaar)

    Ok I solved this.

    All I had to do is change the code to this:

    function my_post_queries( $query ) {
    	// not an admin page and is the main query
    	if ( !is_admin() && $query->is_main_query() && !$query->is_home()) {
    		//$query->set( 'posts_per_page', 5 );
    		$query->set( 'orderby', 'title' );
    		$query->set( 'order', 'ASC' );
    	}
    }
    add_action( 'pre_get_posts', 'my_post_queries' );
    Thread Starter Hakkelaar

    (@hakkelaar)

    Never mind, pasting the following in functions.php DID work after all:

    function my_post_queries( $query ) {
    	// not an admin page and is the main query
    	if ( !is_admin() && $query->is_main_query() ) {
    		$query->set( 'posts_per_page', 5 );
    		$query->set( 'orderby', 'title' );
    		$query->set( 'order', 'ASC' );
    	}
    }
    add_action( 'pre_get_posts', 'my_post_queries' );
    Thread Starter Hakkelaar

    (@hakkelaar)

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)