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 6629619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:17:12+00:00 2026-05-25T22:17:12+00:00

I need to query a category in home page. in index.php file I used

  • 0

I need to query a category in home page. in index.php file I used this script

$all_featured_posts = query_posts(array(‘category_name’=>’featured-programs’));

Then in the header.php file I need to change the title

<title>

<?php



if ( is_home() ) {

    echo 'My site name' ;

} elseif (is_404()) {

    echo '404 Not Found';

} elseif (is_category()) {

    echo ' Category' . wp_title('',0).' | My site name' ;

}
?>

The problem is when I query a category in the index file then the is_home return false ( Tried with is_front_page() also ) Then it alway show the title with the name of the category which I query.

How I can fix it? Thanks you!

  • 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-25T22:17:12+00:00Added an answer on May 25, 2026 at 10:17 pm

    I might be wrong, but I think because you use query_posts(), all your is_* functions change their values. And, well, because you do query a category, is_home() should return false.

    What you can do to solve it, is use new WP_Query(), and get all the posts from it. This way, you will not be affecting the original WP_Query, and thus the is_* functions.

    The code should look like this:

    $query = new WP_Query('category_name=featured-programs');
    while ( $query->have_posts() ) : $query->the_post();
    echo '<li>';
    the_title();
    echo '</li>';
    endwhile;
    
    // Reset Post Data
    wp_reset_postdata();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need this query to select all posts where category = logotypes and full_text
I need query to get data between two days.I tried with this.But it gives
I have an array containing the results of a mysql query on Category, Group
I have the following rules in my .htaccess file RewriteEngine On #1. home page
I have a table with columns Category, Date, Monthly_Revenue . I need a query
I'm building a portal(it's my hobby project) and for my index (home) page i
I have a MYSQL5 database and PHP 5. I need a query for a
In this query I need to remove duplication tutor id and counting them.. SELECT
I need help with a MySQL query. I have three tables: `product_category` ( `id`
Need to query my SQL server from Access using an ADO connection (for example),

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.