Support » Themes and Templates » Topics on frontpage

  • Resolved Beee


    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.

    if (is_category(1)) {
    include(TEMPLATEPATH . ‘/home.php’);
    } else {
    include(TEMPLATEPATH . ‘/single1.php’);

Viewing 15 replies - 1 through 15 (of 17 total)
  • 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:

    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”>

    if (is_home()) {

    <?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

    $query = new WP_Query(‘cat=1’);
    if ($query->have_posts()) : while($query->have_posts() : $query->the_post();

    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:

    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.

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

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

    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?

    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 @

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

    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(); ?>

    And this doesn’t work?

    Are you running any plugins that deal with posts?

    no, none of them is activated…

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

    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)

    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

    ps now = not (in topic above)

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Topics on frontpage’ is closed to new replies.