Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Bladefallcon

    (@bladefallcon)

    Also, any who would like to see this code in action, can visit the website I am currently using it for. It is a website for my church. I wanted a page that would give some information about how to listen to our recorded Sermons, And then I wanted to list the sermons.

    Rather than edit the page every week with a new link, I wanted to just add a new post which would have nothing but the link.

    So, each week, I add a new post, the text of which is simply a link to the mp3 for that week. It is automatically added to the bottom of the page.

    The site is https://www.broadwaybaptistchurch.net
    go to the Sermons page to see this code in action.

    Thread Starter Bladefallcon

    (@bladefallcon)

    Awesome! That worked perfectly. Thanks man. Like I said, the code I was using was something I found, written by someone else. So I didn’t know if what I was using was the best way to go or not. Your code worked great!

    For those who find this posting looking for a solution to the same basic situation, here is the new code that works fine.

    <?php /*
    Template Name: CategoryPostPage
    */ ?>
    
    <?php get_header(); ?>
    
    <div id="content">
    <div id="main">
    
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    		<?php the_content(); ?>
    	<?php endwhile; else: endif; ?>
        // If you want more or less posts to be displayed,
        // change '25' to the number desired.
    	<?php $cat_posts_query_args = array(
        'category_name' => get_the_title(),
        'post_status' => array( 'publish', 'future' ),
        'posts_per_page' => 25
    );?>
    <?php $cat_posts_query = new WP_Query( $cat_posts_query_args ); ?>
    
    <?php if ( $cat_posts_query->have_posts() ) : while ( $cat_posts_query->have_posts() ) : $cat_posts_query->the_post();
        the_content();
    endwhile; endif;
    wp_reset_postdata() ?>
    </div>
    </div>
    
    <?php get_footer(); ?>

    For those who find this, but are even more new at this stuff than me, take the above code, and save it as page.php or anythingelse.php
    Then, create a page (with the same name as the category of posts you want to display) with some text intorducing the posts. Select “CategoryPostPage” as the page’s template.

    The page will now display the text you entered, and then the most recent 25 posts in the category of the same name as the page.

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