I want to have my index.php styled like that, but i can not figure it out:
1. //STUFF// from first post with Category "Meinung" (id=11) and Category "Feature" (id=408)
2.-5. //STUFF// from first four posts of the Category "Meinung", except the one that has been posted already. If there post no.1 would be duplicated in 2-5, it should get the sixth newest post.
Then same as 1-5
6. //STUFF// "Analyse" (id=3) and "Feature" (id=408)
7.-10. //STUFF// Category "Analyse"
11. //STUFF// "Externa" (id=1) and "Feature" (id=408)
12.-15. //STUFF// Category "Externa"
I need the full code.
[[LINK href="http://www.dersalon.org"]]http://www.dersalon.org[[/LINK]]
Victor Teixeira answers:
You just have to change the variable $my_query on each different query.
<?php $my_query1 = new WP_Query('category_name=externa&posts_per_page=4');
while ($my_query1->have_posts()) : $my_query1->the_post();
?>
<?php include (TEMPLATEPATH . "/wp-mulletloop.php"); ?>
<?php endwhile; ?>
<?php $my_query2 = new WP_Query('category_name=externa&posts_per_page=4');
while ($my_query2->have_posts()) : $my_query2->the_post();
?>
<?php include (TEMPLATEPATH . "/wp-mulletloop.php"); ?>
<?php endwhile; ?>
Victor Teixeira comments:
If you want to query multiple categories you need to use category IDs.
<?php $my_query1 = new WP_Query('cat=2,6,17,38&posts_per_page=4');
while ($my_query1->have_posts()) : $my_query1->the_post();
?>
<?php include (TEMPLATEPATH . "/wp-mulletloop.php"); ?>
<?php endwhile; ?>
phil wars comments:
that is what your changes made. not exactly what i need. if you can help contact me at skype: capophilip
Victor Teixeira comments:
I think you need something like this:
<?php $my_query1 = new WP_Query('category_name=externa&posts_per_page=4');
while ($my_query1->have_posts()) : $my_query1->the_post();
$do_not_duplicate[] = $post->ID;
?>
<?php include (TEMPLATEPATH . "/wp-mulletloop.php"); ?>
<?php endwhile; ?>
<?php $my_query2 = new WP_Query('category_name=externa&posts_per_page=4');
while ($my_query2->have_posts()) : $my_query2->the_post();
if (in_array($post->ID, $do_not_duplicate)) continue;
?>
<?php include (TEMPLATEPATH . "/wp-mulletloop.php"); ?>
<?php endwhile; ?>
phil wars comments:
<blockquote>Warning: in_array() [function.in-array]: Wrong datatype for second argument in /www/htdocs/w00bfdc8/wp-content/themes/jq/index.php on line 27
</blockquote>
<?php $my_query1 = new WP_Query('cat=11,408&posts_per_page=1');
while ($my_query1->have_posts()) : $my_query1->the_post();
$do_not_duplicate = $post->ID; ?>
<?php include (TEMPLATEPATH . "/wp-wraploop.php"); ?>
<?php endwhile; ?>
<?php $my_query2 = new WP_Query('category_name=meinung&posts_per_page=4');
while ($my_query2->have_posts()) : $my_query2->the_post();
if (in_array($post->ID, $do_not_duplicate)) continue;?>
<?php include (TEMPLATEPATH . "/wp-mulletloop.php"); ?>
<?php endwhile; ?>
<div class="clear"></div>
phil wars comments:
And still the <strong>cat=11,408</strong> does not give me the newest post which is in the cats 11 AND 408.
phil wars comments:
please victor, can you tell me what i can do??
Dan | gteh answers:
This is a basic example that resets the query after the loop
<?php $my_query = new WP_Query('category_name=featured&posts_per_page=4');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>
<!-- Looping Code -->
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<!-- Do other Loop -->
<?php $my_query = new WP_Query('category_name=newcategory&posts_per_page=4');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>
<!-- Looping Code -->
<?php endwhile; ?>
phil wars comments:
i dont know if that solves my problem. my two main problem are with the feature article and the do_not_dublicate.
1. the feature article needs to be the newest one with categories 11/3/1 and 408.
2. if the feature article is posted and could be in the upcoming posts_per_page=4 it wont be shown there. there are always only 3.
phil wars comments:
if you can help contact me at skype: capophilip
Buzu B answers:
Did you get this question solved?
I can code your index.php, but it would cost you more than $7.
If you are interested, send me a Direct Message.
Buzu.