Hi there,
I am totally new to PHP so please bare with me
I have a Wordpress theme that carries the same header throughout its pages. I want to change the header for the static front-page only and keep the rest the same. I was trying to study the PHP in the functions.php file and came across the following code:
[php]
function wi_page_header() {
$title = ‘’;
$subtitle = ‘’;
if ( is_front_page() && is_home() ) {
$title = get_theme_mod( 'wi_default_blog_title' );
$subtitle = get_theme_mod( 'wi_default_blog_subtitle' );
} elseif ( is_singular( 'post' ) ) {
$title = get_the_title();
$subtitle = get_the_date() . ' - ' . get_the_category_list( ', ' );
} elseif ( is_home() ) {
$blog = get_post( get_option( 'page_for_posts' ) );
$title = $blog->post_title;
$subtitle = get_post_meta( $blog->ID, 'wi_subtitle', true );
} elseif ( is_tax() ) {
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$title = $term->name;
$subtitle = category_description();
} elseif ( is_category() ) {
$title = single_cat_title( '', false );
$subtitle = category_description();
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
$subtitle = tag_description();
} elseif ( is_day() ) {
$title = get_the_date();
$subtitle = __( 'Daily archives', 'weekend' );
} elseif ( is_month() ) {
$title = get_the_date( 'F Y' );
$subtitle = __( 'Monthly archives', 'weekend' );
} elseif ( is_year() ) {
$title = get_the_date( 'Y' );
$subtitle = __( 'Yearly archives', 'weekend' );
} elseif ( is_author() ) {
$title = get_the_author();
$subtitle = __( 'Author archives', 'weekend' );
} elseif ( is_search() ) {
$title = __( 'Search results for: ', 'weekend' ) . get_search_query();
} elseif ( is_404() ) {
$title = __( 'Error 404', 'weekend' );
$subtitle = __( 'Page not found', 'weekend' );
} else {
$title = get_the_title();
$subtitle = get_post_meta( get_the_ID(), 'wi_subtitle', true );
}
echo '<div class="page-header">';
echo '<div class="container">';
echo '<div class="twelve columns">';
echo '<h1 class="page-title text-alt">' . $title . '</h1>';
if ( $subtitle ) {
echo '<div class="page-subtitle">' . $subtitle . '</div>';
}
echo '</div>';
echo '</div>';
echo '</div>';
}
[/php]
I’ve tried various things to try and alter this and have it affect the static front-page only, all but to no avail.
I added a new div ID in the style.css called “portfolio-header” and changed the styling when experimenting but couldn’t get it to apply only to that one page.
Hope someone can help and give me some direction! I am truly a beginner when it comes to PHP and Wordpress I am really trying though!
Regards
Rachael