WordPress.org

Ready to get started?Download WordPress

Forums

How to change post category in this template (20 posts)

  1. SCO7TY
    Member
    Posted 2 years ago #

    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

  2. vtxyzzy
    Member
    Posted 2 years ago #

    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();
  3. SCO7TY
    Member
    Posted 2 years ago #

    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?

  4. SCO7TY
    Member
    Posted 2 years ago #

    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?

  5. SCO7TY
    Member
    Posted 2 years ago #

    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

  6. vtxyzzy
    Member
    Posted 2 years ago #

    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(); ?>
  7. SCO7TY
    Member
    Posted 2 years ago #

    template stays ok but no posts show??

  8. vtxyzzy
    Member
    Posted 2 years ago #

    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.

  9. SCO7TY
    Member
    Posted 2 years ago #

    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.

  10. vtxyzzy
    Member
    Posted 2 years ago #

    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"); ?>
  11. SCO7TY
    Member
    Posted 2 years ago #

    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!

  12. vtxyzzy
    Member
    Posted 2 years ago #

    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.

  13. SCO7TY
    Member
    Posted 2 years ago #

    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?

  14. vtxyzzy
    Member
    Posted 2 years ago #

    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.

  15. SCO7TY
    Member
    Posted 2 years ago #

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

    This is difficult to understand.

  16. vtxyzzy
    Member
    Posted 2 years ago #

    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.

  17. SCO7TY
    Member
    Posted 2 years ago #

    I could send my theme to you?

  18. vtxyzzy
    Member
    Posted 2 years ago #

    I that would probably be a violation of the theme license. You paid for a theme and you should get support from the supplier.

  19. SCO7TY
    Member
    Posted 2 years ago #

    i wouldnt have to send it all would i? I would just rather send it you rather than have to go throuh the whole process of explaining all over again. I am nearly there! :D

  20. vtxyzzy
    Member
    Posted 2 years ago #

    If you don't know where the Loop is coded, you would not know what to send. If you do know where the Loop is coded, you can look at the code for yourself to see how it is done.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags