Call to a member function get_queried_object() on a non-object in..
-
This was discussed in this forum under the title: Pages Posts
[SOLVED] Fatal error: Call to a member function get_queried_object().I am having this same problem with building a theme using a blank theme as the template. I suppose it has to do with my queries in index.php. As I checked throughout editing the index.php it was all good until I called the get_footer().
The footer.php is still just the default and has not yet been edited.
Please Help, thanks in advance.
This is index.php:
<?php get_header(); ?> <?php $tla_plugin_folder = get_bloginfo('wpurl'); $tla_plugin_folder .= '/wp-content/plugins/TLAFeaturedContent/'; $tla_plugin_page = $tla_plugin_folder . 'js/feature_data1.txt'; $tla_plugin_style = $tla_plugin_folder . 'tla_fc_style.css'; ?> <link href="<?php echo $tla_plugin_style;?>" rel="stylesheet" type="text/css"> <script type="text/javascript" src="<?php echo $tla_plugin_folder; ?>js/feature-content.js"></script> <div class="tla_featured_content"> <?php $tla_stored_fc = file_get_contents($tla_plugin_page); echo $tla_stored_fc; ?> </div> <?php get_sidebar('first'); ?> <div id="main_content"> <div class="featured_posts"> <ul id="featured_lists"> <!-- To issue queries I need to hijack $wp_query. So, I can use it later on the page I’m saving it to a temporary variable --> <?php $tempWPQuery = $wp_query; $wp_query = null; // Create a new WP_Query Object $wp_query = new WP_QUERY(); $wp_query->query('posts_per_page=5&category_name=Featured'); while ($wp_query->have_posts()): $wp_query->the_post(); ?> <li> <h3 class="featured_title"><a href="<?php the_permalink(); ?>"><?php $tla_the_title = $post->post_title; echo substr($tla_the_title, 0, 28); ?></a></h3> <p class="featured_excerpt"><?php $tla_the_excerpt = $post->post_excerpt; echo substr($tla_the_excerpt, 0, 50); ?><a href="<?php the_permalink(); ?>" class="click_more">More</a></p> <img src="<?php echo catch_that_image(); ?>" alt="<?php the_title(); ?>" width="60px" height="60px" class="featured_image" /> </li> <?php endwhile; // Reset wp_query to the default $wp_query = null; $wp_query = $temp; ?> </ul> </div> <!-- End of featured_posts div --> <div class="post_lists"> <!-- To issue queries I need to hijack $wp_query. So, I can use it later on the page I’m saving it to a temporary variable --> <?php $tempWPQuery = $wp_query; $wp_query = null; // Create a new WP_Query Object $wp_query = new WP_QUERY(); // Issue a query that returns 4 posts $wp_query->query('posts_per_page=4'); while ($wp_query->have_posts()): $wp_query->the_post(); ?> <li> <h3 class="post_title"><a href="<?php the_permalink(); ?>"><?php $tla_the_title = $post->post_title; echo substr($tla_the_title, 0, 30); ?></a></h3> <p class="post_excerpt"><?php $tla_the_excerpt = $post->post_excerpt; echo substr($tla_the_excerpt, 0, 135); ?><a href="<?php the_permalink(); ?>" class="click_more">More</a></p> <img src="<?php echo catch_that_image(); ?>" alt="<?php the_title(); ?>" width="85px" height="85px" class="post_image" /> </li> <?php endwhile; // Reset wp_query to the default $wp_query = null; $wp_query = $temp; ?> </div> <!-- End of post_lists div --> <br /><br /> <div class="more_lists"> <!-- To issue queries I need to hijack $wp_query. So, I can use it later on the page I’m saving it to a temporary variable --> <?php $tempWPQuery = $wp_query; $wp_query = null; // Create a new WP_Query Object $wp_query = new WP_QUERY(); $wp_query->query('posts_per_page=&&offset=4'); while ($wp_query->have_posts()): $wp_query->the_post(); ?> <div class="recent_posts"> <h3 class="recent_title"><a href="<?php the_permalink(); ?>"><?php $tla_the_title = $post->post_title; echo substr($tla_the_title, 0, 20); ?></a></h3> <img src="<?php echo catch_that_image(); ?>" alt="<?php the_title(); ?>" width="150px" height="150px" class="recent_image" /> <p class="recent_excerpt"><?php $tla_the_excerpt = $post->post_excerpt; echo substr($tla_the_excerpt, 0, 100); ?><a href="<?php the_permalink(); ?>" class="click_more">More</a></p> </div> <?php endwhile; // Reset wp_query to the default $wp_query = null; $wp_query = $temp; ?> </div> <!-- End of more_posts div --> </div> <!-- End of main_content div --> <?php get_footer(); ?>
- The topic ‘Call to a member function get_queried_object() on a non-object in..’ is closed to new replies.