Support » Fixing WordPress » How to change post category in this template

  • I am in desperate need of an asnwer to this! I cannot figure it out at all!

    I basically just want to change the category of the posts for this template, can someone tell where in this template i can do this? – http://pastebin.com/JH1EUTV8

    Thanks in advance

Viewing 15 replies - 1 through 15 (of 19 total)
  • The code below seems to indicate that the category is a Theme Option:

    $blog_cats = isset( $et_ptemplate_settings['et_ptemplate_blogcats'] ) ? (array) $et_ptemplate_settings['et_ptemplate_blogcats'] : array();

    Yes, the original template (part of the theme) has page settings where i can choose the category. But i copied the template and changed the appearance slightly, but now i have copied it i dont get the page settings. So i just need to know what i need to add/change in the code to make it select a category?

    Fianlly found out the ID number of the category i want to use if this helps at all its ID-18

    There must be some sort of code i can place in the template with the ID number to bring up posts only from that category?

    I think i nearly have it! If i use this code –

    <?php
    query_posts('cat=1');
    while (have_posts()) : the_post();
    the_content();
    endwhile;
    ?>

    Then just the posts from a category i want show, problem is i have no idea where to put it without messing my template up!

    This is what the page looks like so far – http://completemuscleandfitness.com/index.php/344-2/

    and this is the template code without the above code in – http://pastebin.com/dLXvZZTp

    I think this will do what you want. Modify your template by adding the new code between the ‘id=”main”‘ and ‘if ( have_posts()’ lines:

    <!-- Start Main Window -->
    			<div id="main">
    			<?php global $wp_query;
    			query_posts(
    			   array_merge(
    			      $wp_query->query,
    			      array('cat' => 18)
    			   )
    			); ?>
    			<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    template stays ok but no posts show??

    Are you sure that the cat id is 18 and there are posts in that category? Try the id of a different category as a test.

    I’ve just tried a different category ID and still nothing showed up. I use Reavel ID plugin to get the ID of categories.

    Here is my code after i edited with what you suggested, can you spot anything wrong?

    http://pastebin.com/NcxvqM4k

    Thanks for the help, i’ve struggled to get someone to help me out with this!

    Thanks.

    OK, you said that this code:

    <?php
    query_posts('cat=1');
    while (have_posts()) : the_post();
    the_content();
    endwhile;
    ?>

    shows the posts you want, so try replacing this:

    <?php global $wp_query;
    			query_posts(
    			   array_merge(
    			      $wp_query->query,
    			      array('cat' => 18)
    			   )
    			); ?>

    with this:

    <?php query_posts("cat=18"); ?>

    One step further!

    Now it shows only the posts i want it to, but its the full post with no thumbnail. I was after something like my home page with a summary and image.

    http://completemuscleandfitness.com/index.php/344-2/

    I probably need to add some coding in there for that as well!

    Just compare the Loop coding for the Home page to your template.

    If you have a static home page, look in the template assigned to that page. If not, look in home.php if it exists, or else in index.php.

    Sorry, i dont mean to sound stupid, but whats loop coding?

    I dont have a static one i have both home.php and index.php

    Again thanks for your help and patience

    EDIT, just checked both index and home, home only has 3 lines of code and home has 12. Does that sound right?

    Where the Loop is coded depends entirely on your theme. It is the code between the ‘while (have_posts())` and the corresponding ‘endwhile;’ or closing brace.

    You have lost me now! I dont have that in either Home.php or index.php

    This is difficult to understand.

    As I said, the location of the Loop code depends entirely on your theme. Look for files named ‘loop.php’ or ‘loop-something.php’.

    If you are using a free theme, post a link to its download page here so I can take a look. If you are using a purchased theme, I won’t be able to look at the code, so you will need to contact the theme supplier for further assistance.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘How to change post category in this template’ is closed to new replies.