What have you put in place of..
<!-- Do special_cat stuff... -->
If you havn’t replaced that with anything then you won’t get anything.. that’s to be expected..
If you’re simpy giving an example above and you’re saying the query is returning an empty result, does removing the category parameter then yield results?
If it does, then i’d guess there’s a problem with the name (category_name parameter is case sensitive iirc).
Try a simple cat name like Test or test, then create 1 test post in that cat and give it a try in your query above.
Process of elimination..
offcourse I replaced <!– Do special_cat stuff… –>
my exact code now:
<?php $my_query = new WP_Query('showposts=1'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p>hello world</p>
<?php endwhile; ?>
The output is 3 times “hello world”. I have a total of 7 post.
Why 3? To me it’s a total mystery!
It should be 1, since you have showposts=1 …
You shouldn’t be placing this inside an existing loop, else you’ll get this result for an equal amount of times to the current loop..
If the existing loop has 3 matches, and runs the above code each time, you’ll get hello world that amount of times.
no, here my total page code
<?php
/**
* Template: Index.php
*/
get_header();
?>
<div class="inhoudcontainer">
<?php $my_query = new WP_Query('category_name=news'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php the_title()?>
<br /><br />
<?php endwhile; ?>
</div> <!-- END INHOUDCONTAINER-->
<?php get_footer(); ?>
I have a category calles news
Are you using this as a template file?
If this a template file, and the file is named index.php, and also resides in your theme folder, you’ll end up with a conflict, since index.php is a reserved name for the root file of the theme.
Do you need this file for attaching to pages? because that’s what “Page Templates” are for, which is what the top most “Template:” does, to denote that it is a Page Template file.
If you’re attaching this to a page, no problem there, i just think if you’re naming it index.php the file will be having a conflict of interest.
Template names also shouldn’t read like this.
* Template: Index.php
but like so…
* Template: filename
without the extension (although the file must be a PHP file).
I copied my theme to another Worpress 2.8.4 installation and it worked fine!
So I installed wordpress allover on my localhost and the code works !!
still, many thanks for your help !
🙂 Good stuff…
Mark resolved if all is ok (just to the right of the post).. —->