Forum Replies Created

Viewing 15 replies - 91 through 105 (of 109 total)
  • Thread Starter foochuck

    (@foochuck)

    Just figured it out, was missing: $my_query-> before the_post on this line:

    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

    Thanks all!!!

    Thread Starter foochuck

    (@foochuck)

    Updated the code:

    <?php
    $cat = 10;
    $showposts = -1; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
       'category__in' => array( $cat ),
       'posts_per_page' => $showposts,
       'caller_get_posts' => $do_not_show_stickies,
       'order' => 'asc'
       );
    $my_query = new WP_Query($args); 
    
    ?>

    But the same result:

    https://www.sopranos.foochuck.com/the-test-page/

    Thread Starter foochuck

    (@foochuck)

    Here’s a link to the page that was generated by that code:

    https://www.sopranos.foochuck.com/the-test-page/

    It’s not working correctly…

    Thread Starter foochuck

    (@foochuck)

    I tried that code and it processed a page that kept looping and all of the content was blank. Here’s my whole template page:

    <?php
    /*
    Template Name: Seasons
    */
    
    get_header(); ?>
    <div id="content-container">
    
    <div id="content">
    
    	<div id="body">
    
    <?php
    $cat = 10;
    
    $showposts = -1; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
       'category__in' => $cat,
       'posts_per_page' => $showposts,
       'caller_get_posts' => $do_not_show_stickies,
       'order' => 'asc'
       );
    $my_query = new WP_Query($args); 
    
    ?>
    
    	<?php if( $my_query->have_posts() ) : ?>
    
    		<?php while ($my_query->have_posts()) : the_post(); ?>
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    
    				<div class="date">
    					<span class="month"><?php the_time('M') ?></span>
    					<span class="day"><?php the_time('j') ?></span>
    					<span class="year"><?php the_time('Y') ?></span>
    				</div>
    
    				<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'elegant-grunge'), get_the_title()); ?>"><?php the_title(); ?></a></h3>
    
    				<?php if ( get_option("show_author") ) : ?>
    				<div class="author"><?php the_author() ?></div>
    				<?php endif ;?>
    
    				<!-- <div class="info">by <?php the_author() ?></div> -->
    
    				<div class="entry">
    					<small><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'elegant-grunge'), get_the_title()); ?>"><?php the_excerpt(__('Continue reading', 'elegant-grunge')); ?></a></small>
    				</div>
    
    				<div class="clear"></div>
    
    				<p class="metadata">
    					<?php comments_popup_link(__('no comments', 'elegant-grunge'), __('1 comment', 'elegant-grunge'), __('% comments', 'elegant-grunge')); ?>
    					<!-- <?php the_tags('&nbsp;&nbsp;|&nbsp;&nbsp;'.__('tags:', 'elegant-grunge').' ', ', ', ''); ?> -->
    					<?php if ( count(($categories=get_the_category())) > 1 || $categories[0]->cat_ID != 1 ) : ?>
    					 | <?php _e('posted in', 'elegant-grunge')?> <?php the_category(', ') ?>
    					<?php endif; ?>
    					<?php edit_post_link(__('Edit', 'elegant-grunge'), '&nbsp;&nbsp;|&nbsp;&nbsp;', ''); ?>
    				</p>
    
    			</div>
    
    			<div class="hr"><hr /></div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="next"><?php next_posts_link(__('&laquo; Older Entries', 'elegant-grunge')) ?></div>
    			<div class="previous"><?php previous_posts_link(__('Newer Entries &raquo;', 'elegant-grunge')) ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center"><?php _e('Not Found', 'elegant-grunge') ?></h2>
    		<p class="center"><?php _e('Sorry, but you are looking for something that isn\'t here.', 'elegant-grunge') ?></p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    	<?php if ( get_option('page_setup') != 'no-sidebar'  ) get_sidebar(); ?>
    
    </div>
    <div class="clear"></div>
    </div>
    
    <?php get_footer(); ?>
    Thread Starter foochuck

    (@foochuck)

    I have updated the code to this:

    <?php
    $cat = 10;
    
    $showposts = -1; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
       'category__in' => $cat,
       'posts_per_page' => $showposts,
       'caller_get_posts' => $do_not_show_stickies,
       'order' => 'DESC'
       );
    $my_query = new WP_Query($args); 
    
    ?>

    Followed by:

    <?php if( $my_query->have_posts() ) : ?>
    
    		<?php while ($my_query->have_posts()) : the_post(); ?>
    Thread Starter foochuck

    (@foochuck)

    t31os_ : Would I simply set the $cat variable to 10 (the cat_ID I want to display)?

    Thread Starter foochuck

    (@foochuck)

    Okay so my cat_ID is 10.

    How would I work that into this block of code:

    <?php
    // page id 21 will get category ID 12 posts, page 16 will get category 32 posts, page 28 will get category 17 posts
    if (is_page('21') ) {
    $cat = array(12);
    } elseif ( is_page('16') ) {
    $cat = array(32);
    } elseif ( is_page('28') ) {
    $cat = array(17);
    } else {
    $cat = '';
    }
    
    $showposts = -1; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
       'category__in' => $cat,
       'showposts' => $showposts,
       'caller_get_posts' => $do_not_show_stickies
       );
    $my_query = new WP_Query($args); 
    
    ?>
    Thread Starter foochuck

    (@foochuck)

    I have one last question for you (I hope!):

    I can create a new template page, no problem. The only question or reference material I need:

    What is the PHP code I put on the page to display a specific category post and where can I find the category ID to plug into that PHP?

    Thread Starter foochuck

    (@foochuck)

    Sorry SS_Minnow – I’m a bit slow today ??

    I think everything you posted is making sense to me now. I appreciate your help and again apologize for the ‘internet forum’ confusion ??

    Thread Starter foochuck

    (@foochuck)

    I think I understand what you are saying to do now – create a template for this as a php file and then apply that template to a new page that I create, correct?

    I have never created a page template and have a few questions:

    1. I’m guessing I can just upload the new page I create to my theme folder and it will show up in the WordPress Editor

    2. For the page that I create as a template, how do I pass the variable to it of which category I want it to display? From there I can figure out the other options from the link you first sent – https://codex.www.ads-software.com/Template_Tags/wp_list_categories

    Thanks

    Thread Starter foochuck

    (@foochuck)

    SS_Minnow : I’m not sure I understand the process you are describing. Could you show me a sample or a tutorial for what you are advising?

    Thread Starter foochuck

    (@foochuck)

    Sorry for my confusion. I’m going to describe this again…

    On this page:

    https://www.sopranos.foochuck.com/category/episode-guide/season-1/

    It displays 9 blog posts that are associated with the ‘season 1’ category. The posts on this page are displayed from the newest post at the top, down to the oldest post at the bottom.

    I would like to reverse that listing so that the oldest posts in the category are shown at the top of the page and the newest posts show up at the bottom of the page.

    I only want this change to show up on specific categories and not all of my blog pages (for example, newest to oldest works fine on my blog’s homepage).

    I understand I may need to customize something or install a plug-in to get this to work, so I’m asking where to start and if anyone knows of a solution to this?

    Thanks!

    Thread Starter foochuck

    (@foochuck)

    SS_Minnow : Won’t that effect my homepage as well though? I would just like to customize the appearance on the category results page.

    Thread Starter foochuck

    (@foochuck)

    SS_Minnow – See my previous post. I’m not trying to change the order of the menu – but rather the posts that show up on my categorys page.

    Thread Starter foochuck

    (@foochuck)

    SS_Minnow: It looks like what you sent isn’t what I’m looking for.

    On this page:

    https://www.sopranos.foochuck.com/category/episode-guide/season-1/

    I want the posts that show on that page to show from oldest to newest. By default it shows the newest posts first.

    How can I change that just on this specific category page?

Viewing 15 replies - 91 through 105 (of 109 total)