Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6025749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:20:44+00:00 2026-05-23T04:20:44+00:00

<?php if ( is_home() ) { <?php if ( have_posts() ) : while (

  • 0
<?php   
 if ( is_home() ) {

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>


  <div id="post">

      <?php the_content(); ?>

    </div>


    <?php endwhile;?>


    <?php endif; ?>
} else if (is_page() ) {

 $category = get_post_meta($posts[0]->ID, 'category', true);
}
if ($category) {
$cat = get_cat_ID($category);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_per_page = 4; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
'category__in' => array($cat),
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => $post_per_page,
'caller_get_posts' => $do_not_show_stickies
  );
  $temp = $wp_query;  // assign orginal query to temp variable for later use   
  $wp_query = null;
  $wp_query = new WP_Query($args); 
   if( have_posts() ) : 
    while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

  <div id="post">

      <?php the_content(); ?>
    </div>


<?php endwhile; ?>
<?php endif; 

$wp_query = $temp;  

 }  
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:20:45+00:00Added an answer on May 23, 2026 at 4:20 am

    On line #4 you are opening a new PHP block even though the old one hasn’t been closed yet.

    You’ll want to delete the preceding <?php on that line. You don’t need it.

    Additionally:

    You have an extra endwhile; in your else block. The while loop is started and closed within the if ( is_home() ) { block.

    The code starting with } else if (is_page() ) { is not in a PHP block. You should either open a <?php block or not close the preceding one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a category template in Wordpress for all posts that are in
is it possible to use $.post(/home/ACOUNT_NAME/ACOUNT_DOMAIN/script.php) to access a php file outside the main
<div class=home-thumbs bottom-thumbs> <?php $home_query_bottom = new WP_Query(cat=&showposts=20&offset=5); $b = 0; ?> <ul class=thumbs>
I'm trying to post to WordPress using curl via PHP - I'm posting using
Can a post be hidden from home page, archive view, category lists etc. and
I'm trying to have a post from a certain category display on my static
I have a post list on my homepage that is displaying all posts in
Situation: I have a few hundred posts each belonging to a particular category. A]
Let's say we have index.php and it is stored in /home/user/public/www and index.php calls
I have folder home/admin. In this folder there is index.php. When i access to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.