php - Allowed to use a second if statement? -



php - Allowed to use a second if statement? -

am allowed utilize sec "if" statement @ end of existing if statement?

i using "code a" create conditional title tags wordpress website. originally, "code a" did not include "code b", read utilize "code b" adding towards end of existing if statement. "code a" correct?

example of output of code a: category "chicken" , website name "recipes" , "page 3":

title displayed in browser: chicken - recipes - page 3

. code a

<title> <?php if (is_category()) { wp_title(''); echo ' - '; } elseif (function_exists('is_tag') && is_tag()) { single_tag_title(); echo ' - '; } elseif (is_archive()) { wp_title(''); echo ' archive - '; } elseif (is_page()) { echo wp_title(''); echo ' - '; } elseif (is_search()) { echo 'search &quot;'.wp_specialchars($s).'&quot; - '; } elseif (!(is_404()) && (is_single()) || (is_page())) { wp_title(''); echo ' - '; } elseif (is_404()) { echo 'not found - '; } if (is_home()) { bloginfo('name'); echo ' - '; bloginfo('description'); } else { bloginfo('name'); } if ($paged>1) { echo ' - page '. $paged; } ?> </title>

. code b: instructions copied website:

another suggestion, i’m still tinkering titles add together page number end of title if archive or whatever has multiple pages. way avoid duplicate titles (which apparently not advisable search engines).

the code used simple:

if ($paged>1) { echo '- page ', $paged; }

i set code right @ end after else.

yes, code correct. receiving kind of error? thing might want remove "echo" in front end of 3rd wp_title() call.

php wordpress if-statement

Comments

Popular posts from this blog

php - How to pass multiple values from url -

php - Laravel not returning controller -

c# - Confused on how to specify a Platform and Version while using ChromeOptions for RemoteWebDriver with Selenium donNet since recent updates -