WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Topics on frontpage (18 posts)

  1. Beee
    Member
    Posted 7 years ago #

    I know the question is already been asked but after reading this forum for 2 hours, I still can't find the answer (maybe due to my lack of knowledge in php).

    i thought I knew some, but I can't seem to get just cat_id=1 on the frontpage, without showing any other (sub)directories.

    i assume the answer is short, but if somebody could give it... please...

    I looked at the conditionals for including a file but I don't know which get command to give to show only cat_id=1

    I know include isn't the correct one, but I don't which is.

    <?php
    if (is_category(1)) {
    include(TEMPLATEPATH . '/home.php');
    } else {
    include(TEMPLATEPATH . '/single1.php');
    }
    ?>

  2. Kafkaesqui

    Posted 7 years ago #

    is_category() is a Conditional Tag for use in category queries. It should always return false on the home page.

    There is in_category(). It's more useful for choosing between alternative actions to perform (such as design considerations). If you want to "show only cat_id=1" on your blog's home page, you can use query_posts(), but before doing that see:

    http://wordpress.org/support/topic/51925#post-284690

  3. Beee
    Member
    Posted 7 years ago #

    I totally have to switch, used to work (and still do) work with pivot as well.... but if i get this down it's much better.... now only learning how to display what

    i've looked at the query_posts()...

    so after reading I thought this would solve it.

    --
    <?php get_header(); ?>

    <div id="content" class="narrowcolumn">

    <?php
    if (is_home()) {
    query_posts("cat=1");
    }
    ?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    but still this also lists cat_id=any

    I also tried what you linked, but that didn't work either.... really annoying when extensive knowledge is missing and you have to ask others

    <?php
    $query = new WP_Query('cat=1');
    if ($query->have_posts()) : while($query->have_posts() : $query->the_post();
    ?>

  4. moshu
    Member
    Posted 7 years ago #

    What is exactly what you want to do? To exclude some categories from the homepage and to display only the one(s) you selected?
    (Instead of technical code questions it is always better to describe the goal you want to achieve; most likely it has been solved already.)

    To control which categories are displayed on the frontpage - use a plugin: http://ryowebsite.com/?p=46

  5. Beee
    Member
    Posted 7 years ago #

    I want to create a pic log where on the frontpage i list 1 day per item. in this item are i.e. 2 images which both link to an entry, which is a gallery.

    the plugin works very nice.... i'll use it (for now)... but i have to get into that mysql since that's the way.

  6. Michael Bishop

    Posted 7 years ago #

    I usually just create a home.php file, and then do the query posts on that template.

  7. Beee
    Member
    Posted 7 years ago #

    i tried that, but my knowledge obviously isn't up2date since i last used it because i couldn't achieve it.

  8. Michael Bishop

    Posted 7 years ago #

    Generally I simply use

    <?php $wp_query->set( 'cat', '1' ); ?>
    <?php query_posts( '' ); ?>

    Just above the start of the loop.

    This makes the next previous posts link work, vs the standard query_posts

    What version are you running by the way?

  9. Beee
    Member
    Posted 7 years ago #

    i run the latest, downloaded 2 days ago.

    does this string has to come before the <div id=content> ?

    i'm working on a babelog, which is in a dev directory at my webserver @ http://www.rubber-visions.com/wp/

  10. Michael Bishop

    Posted 7 years ago #

    After the div, directly before the loop: <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

  11. Beee
    Member
    Posted 7 years ago #

    my code reads

    <?php get_header(); ?>

    <div id="content" class="narrowcolumn">

    <?php $wp_query->set( 'cat', '1' ); ?>
    <?php query_posts( '' ); ?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

  12. Michael Bishop

    Posted 7 years ago #

    And this doesn't work?

    Are you running any plugins that deal with posts?

  13. Beee
    Member
    Posted 7 years ago #

    no, none of them is activated...

  14. Michael Bishop

    Posted 7 years ago #

    Indeed I've tested this in 2.0.5 and it doesn't work. I'll get to the bottom of it.

  15. Beee
    Member
    Posted 7 years ago #

    i have the cat_visibility plugin, so i can manage for now, but I do think i need this function later on, since I want to include posts in a page as well (would like to have it work as a category because of nice looking URI)

    [offtopic]
    since we're on now working 'parts' here.
    i saw the mod rewrite doesn't change when you change a topic's title. Since i'm knew to WP i don't know if that should be or not, but doesn't seem logical
    [/offtopic]

  16. Beee
    Member
    Posted 7 years ago #

    ps now = not (in topic above)

  17. Beee
    Member
    Posted 7 years ago #

    would this WP query also go for pages ???

    I would like a page to 'work' as a category (because of the permalinks) which holds then all pics from 1 girl.

  18. Beee
    Member
    Posted 7 years ago #

    I think I know what went wrong...
    I had a home.php in the same directory since it belongs to another site and I wanted to copy thigns from it.

    I just looked into hierarchy and I think i solved by removing this home.php and adding it to the index.

Topic Closed

This topic has been closed to new replies.

About this Topic