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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:05:35+00:00 2026-06-01T17:05:35+00:00

This is part of the wordpress code and I don’t understand it: if (

  • 0

This is part of the wordpress code and I don’t understand it:

if     ( is_404()            && $template = get_404_template()            ) :
elseif ( is_search()         && $template = get_search_template()         ) :
elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
elseif ( is_front_page()     && $template = get_front_page_template()     ) :
elseif ( is_home()           && $template = get_home_template()           ) :
elseif ( is_attachment()     && $template = get_attachment_template()     ) :
    remove_filter('the_content', 'prepend_attachment');
elseif ( is_single()         && $template = get_single_template()         ) :
elseif ( is_page()           && $template = get_page_template()           ) :
elseif ( is_category()       && $template = get_category_template()       ) :
elseif ( is_tag()            && $template = get_tag_template()            ) :
elseif ( is_author()         && $template = get_author_template()         ) :
elseif ( is_date()           && $template = get_date_template()           ) :
elseif ( is_archive()        && $template = get_archive_template()        ) :
elseif ( is_comments_popup() && $template = get_comments_popup_template() ) :
elseif ( is_paged()          && $template = get_paged_template()          ) :
else :
    $template = get_index_template();
endif;

A colon can replace a curly bracket in PHP. So if I substitute the colons, I get this:

if     ( is_404()            && $template = get_404_template()            ) {
   elseif ( is_search()         && $template = get_search_template()         ) {
      elseif ( is_tax()            && $template = get_taxonomy_template()       ) {
      ...
      }
   }
}
else

Makes no sense to me, because each elseif is missing its opening if.

  • 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-06-01T17:05:36+00:00Added an answer on June 1, 2026 at 5:05 pm

    Reggie,

    colons in if/else statements in PHP : it’s NOT about replacing braces
    but a PAIR of braces.

    Example :

    if ($a) : doThis();
    elseif ($b) : doThat();
    else : doTheOther();
    endif;
    

    would become

    if ($a) { doThis(); }
    elseif ($b) { doThat(); }
    else { doTheOther(); }
    

    OR (since it’s just one statement and not a block of statements)

    if ($a) doThis();
    elseif($b) doThat();
    else doTheOther();
    

    Reference : Alternative Syntax for Control Structures


    As for this specific piece of code :

    if     ( is_404()            && $template = get_404_template()            ) :
    elseif ( is_search()         && $template = get_search_template()         ) :
    elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
    

    it translates to

    if     ( is_404()            && $template = get_404_template()            )  
        { /* DO NOTHING */ }
    elseif ( is_search()         && $template = get_search_template()         )  
        { /* DO NOTHING */ }
    

    Hint : The elseif statement does NOT include the other elseif statements. (like elseif ($a) { elseif($b) {} })

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

Sidebar

Related Questions

This is the .htaccess code for permalinks in WordPress. I don't understand how this
This code is part of a wordpress plugin. THe page breaks somewhere in the
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =
This part of my code is used to award a grade to a student
It seems that this part of my code is where the exception occurs: c
I have this part of code in my functions.php: function cc_admin_enqueue_scripts($hook) { $file_dir=get_bloginfo('template_directory'); wp_enqueue_script('media-upload');
I am trying to learn and writting this part of code. while testing few
I have some code (it's part of a wordpress plugin) which takes a text
I use this code for upload image: http://vikaskanani.wordpress.com/2011/01/11/android-upload-image-or-file-using-http-post-multi-part/ I replaced bm = BitmapFactory.decodeFile(/data/data/fshizzle.com/files/image.jpg); and
This is a wordpress question. I am trying to use a bit of code

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.