• Hi All,

    Sorry for bring up this old one again, but i am having hair pulling out problems with this!

    I am converting a Theme for a friend, and have gone through and tried changing the PHP for the main styled page using

    <?php
    $catID = 0;
    if (is_page('18')) {
      $catID=3;
    } elseif (is_page('27')) {
      $catID=4;
    }
    
    if ($catID) {
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts("cat=$catID&paged=$paged");
    } ?>

    But its not having any of it!

    Here is the code for the whole page that I have created for it:

    <?php
    /*
    Template Name: Challenge Page
    */
    ?>
    <?php get_header(); ?>
    
    	<div id="featured">
            <div id="page-title" class="content">
                <h2 class="page"><?php the_title(); ?></h2>
            </div>
        </div>
    
        <!-- Content Starts -->
    	<div id="main-content" class="page">
        <div class="content">
    		<div class="col-left">
    			<div id="main">
    
                    <div class="post">
                        <h2><?php _e('Challenge Posts',woothemes); ?></h2>
    
                        <ul>
    
                 <?php
    				$catID = 0;
    				if (is_page('18')) {
    				$catID=3;
    				} elseif (is_page('27')) {
    				$catID=4;
    }
    
    if ($catID) {
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts("cat=$catID&paged=$paged");
    } ?>
    
                </div><!-- main ends -->
            </div><!-- .col-left ends -->
    
            <?php get_sidebar(); ?>
    
        </div>
        </div><!-- Content Ends -->
    
    <?php get_footer(); ?>

    You can view the page that I am working on here: https://www.theundentabletrust.co.uk/new/?page_id=18

    All help is appreciated, I’m already going bald, i don’t need the extra help!

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • You said:

    But its not having any of it!

    So what’s the problem with it?

    Thread Starter justin123

    (@justin123)

    its not working, posts form category 3 and for are not showing on the Challenge page?

    So what happens if you print each of your variables, are the values as they should be?..

    Thread Starter justin123

    (@justin123)

    Sorry i don’t understand? I’m not really a PHP whiz!

    I know that the category ID’s and pages ID’s are correct, so that should work, right?

    I assume you are attaching this template to pages 18 and 27, is that correct?

    What’s the value when you ..

    print $catID;

    after..

    <?php
    				$catID = 0;
    				if (is_page('18')) {
    				$catID=3;
    				} elseif (is_page('27')) {
    				$catID=4;
    }

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display a singular category on a page, an oldie but a goodie!’ is closed to new replies.