• workathomenews

    (@workathomenews)


    Hi Everyone

    I’m having a bit of an issue with the following WP Blog… https://www.opportunitiesworkathome.com/Newsletter/

    I am using an amazing theme which I really like, but it appears as though the categories script for the index.php file is missing.

    What I want to be able to do is sent people to a category link and they will see the posts in that category only.

    Can someone help me out with the script.

    Thanks

    Dave

Viewing 12 replies - 16 through 27 (of 27 total)
  • Thread Starter workathomenews

    (@workathomenews)

    I’m pretty sure I’m missing something in the index.php that allows wordpress to do all of the filtering.

    huggie

    (@huggie)

    Having read these usage notes, I think you have the wrong type of theme for what you’re trying to achieve.

    Thread Starter workathomenews

    (@workathomenews)

    I’ve read the usage notes also. I have change the setting in the index.php to allow for displaying posts instead of pages. Just missing the script that allows wordpress to filter by category so that this will work:

    /index.php?cat=category_name

    Can’t I just install/add the script that performs this function into the index.php file?

    huggie

    (@huggie)

    I guess you could try passing in like you’ve got there and then change the query_posts

    query_posts(category_name=$cat);

    Thread Starter workathomenews

    (@workathomenews)

    I’ve tried implementing that and it’s definitely getting closer, I have no posts coming up now when I use the cat.

    Here’s the whole query_posts line

    <?php query_posts(‘post_type=post&order=asc&category_name=$cat’); ?>

    And I’m trying to call it using

    https://www.opportunitiesworkathome.com/Newsletter/index.php?cat=introducton

    I have a category Called Introduction which has slug introduction with one post in it.

    I’m guessing it’s a syntax problem, but I’m very confident this will work.

    Thread Starter workathomenews

    (@workathomenews)

    Just a thought, not much of a php wiz, but do I have to define cat or something like that somewhere?

    huggie

    (@huggie)

    You should have double quotes otherwise $cat will be interpreted literally.

    try:

    <?php
       $cat = $_GET['cat'];
       query_posts("post_type=post&order=asc&category_name=$cat");
    ?>

    Thread Starter workathomenews

    (@workathomenews)

    That’s IT!

    You are a genius huggie. Thank-you so much for your help.

    Dave

    huggie

    (@huggie)

    No problem, I’m off to be now though as it’s 3:35am here!

    Thread Starter workathomenews

    (@workathomenews)

    Can I trouble for one more tidy up… is there a way that I can make it display a specific post/category if no category is parsed? Sort of like a catch-all/default.

    Thanks again

    Thread Starter workathomenews

    (@workathomenews)

    Sorry just saw your last post… thank-you so much for all of your help, I’m pretty sure I can find a way to create the variable as a default first myself. Have a good sleep.

    Dave

    huggie

    (@huggie)

    Try this:

    <?php $cat = (empty($_GET['cat'])) ? 'introduction' : $_GET['cat']; ?>;

    Of course you should also probably check that if the category is entered that it exists.

Viewing 12 replies - 16 through 27 (of 27 total)
  • The topic ‘Categories Script for index.php’ is closed to new replies.