[Resolved] Multiple categories on index page
I’m struggling with get_posts, WP_Query, and query posts. I’ve read through The Loop, Custom Queries and about a bazillion other helper forums. I’ve even tried about a hundred examples from forums all over. I just can’t seem to get what sounds like a simple task to work. I wish to show two categories on custom taxonomy index page. These are also linked to custom post types, which appear to have caused issues in older versions of WordPress.
Custom Taxonomy 1: Home Location – State – City
Custom Taxonomy 2: Visiting Location – State – City
I have template files isolating by location:
taxonomy-home-location-new-york.php – example
I have the visiting location set so that it auto changes to and from by date. I then want the visitor to show up in the home-location index page.
As soon as I add a query of any type, all of the content on the page disappears. I only get the header and nav. I’ve stripped out all formatting and tried it with the simplest query I could find and it still doesn’t work. Here is the code:
<?php /** * The main template file. * * * @package Sunspot * @since Sunspot 1.0 */ define('WP_USE_THEMES', false); get_header(); ?> <?php $my_query = new WP_Query('showposts=2&cat=7,28'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"> <?php the_title(); ?></a> <?php the_content(); ?> //optional, can also be the_excerpt <?php endwhile; ?> <?php get_template_part( 'primary_nav' ); ?>
As a note: I’ve also tried it with and without
define('WP_USE_THEMES', false);in the header’s opening line.
Any insight on what I’m doing wrong would be immensely appriciated.
- The topic ‘[Resolved] Multiple categories on index page’ is closed to new replies.