I'm working on a Wordpress site and I have a header image on the homepage. It's only showing up on the homepage but I need it to show on every page. I found this code in the header.php file which I believe needs to be changed, but I'm not very familiar with php.
This is the code for the header image in the header.php file:
<?php $disable_page_title = get_post_meta( get_the_ID(), 'minimal_portfolio_page_title', true );
if( $disable_page_title !== 'on' ): ?>
<?php if( !is_front_page()): ?>
<section class="page-header jumbotron <?php if ( get_header_image() ) : ?>bg-image<?php endif; ?>" <?php if ( get_header_image() ) : ?> style="background-image:url('<?php echo esc_url( get_header_image() ); ?>');" <?php endif; ?>>
<?php if ( get_header_image() ) : ?><span class="bg-overlay"></span><?php endif; ?>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="title-wrap">
<?php if( is_page() || is_single() ){ ?>
<h2 class="page-title"><?php echo esc_html( get_the_title() ); ?></h2>
<?php } elseif( is_search() ){ ?>
<?php /* translators: %s: search term */
$page_title = sprintf( esc_html__( 'Search Results for: %s', 'minimal-portfolio' ), get_search_query() );
?>
<h2 class="page-title"><?php echo esc_html( $page_title ); ?></h2>
<?php }elseif( is_404() ){ ?>
<h2 class="page-title"><?php echo esc_html( 'Page Not Found: 404', 'minimal-portfolio' ); ?></h2>
<?php }elseif( is_home() ){ ?>
<h2 class="page-title"><?php single_post_title(); ?></h2>
<?php } else{
the_archive_title( '<h2 class="page-title">', '</h2>' );
}
if( $minimal_portfolio_breadcrumb_status ):
minimal_portfolio_breadcrumbs();
endif;
?>
</div>
</div>
</div>
</div>
</section>
<?php endif;
endif; ?>
Thank you!
Edit: This is how it shows on all pages but the home page. But I would like it to show the full header instead of only a section of it with the page title.
Header
This is the home page, where it shows the full header and how I'd like it to show on every page instead of how it does in the image above.
Home Header
You are not familiar with PHP so you can use this plugin for the header image.
https://wordpress.org/plugins/unique-headers/
I think its work for you
Remove the below-attached code from header.php
<?php $disable_page_title = get_post_meta( get_the_ID(), 'minimal_portfolio_page_title', true );
if( $disable_page_title !== 'on' ): ?>
<?php if( !is_front_page()): ?>
<section class="page-header jumbotron <?php if ( get_header_image() ) : ?>bg-image<?php endif; ?>" <?php if ( get_header_image() ) : ?> style="background-image:url('<?php echo esc_url( get_header_image() ); ?>');" <?php endif; ?>>
<?php if ( get_header_image() ) : ?><span class="bg-overlay"></span><?php endif; ?>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="title-wrap">
<?php if( is_page() || is_single() ){ ?>
<h2 class="page-title"><?php echo esc_html( get_the_title() ); ?></h2>
<?php } elseif( is_search() ){ ?>
<?php /* translators: %s: search term */
$page_title = sprintf( esc_html__( 'Search Results for: %s', 'minimal-portfolio' ), get_search_query() );
?>
<h2 class="page-title"><?php echo esc_html( $page_title ); ?></h2>
<?php }elseif( is_404() ){ ?>
<h2 class="page-title"><?php echo esc_html( 'Page Not Found: 404', 'minimal-portfolio' ); ?></h2>
<?php }elseif( is_home() ){ ?>
<h2 class="page-title"><?php single_post_title(); ?></h2>
<?php } else{
the_archive_title( '<h2 class="page-title">', '</h2>' );
}
if( $minimal_portfolio_breadcrumb_status ):
minimal_portfolio_breadcrumbs();
endif;
?>
</div>
</div>
</div>
</div>
</section>
<?php endif;
endif; ?>
And add this code in your page.php
<?php if( get_header_image() ) : ?>
<div class="header-banner">
<img src="<?php header_image(); ?>" width="<?php echo absint( get_custom_header()->width ); ?>" height="<?php echo absint( get_custom_header()->height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
</div>
Related
I actually struggling with problem on this URL: Problematic URL
The problem can be described like this:
Page on that URL was set as main blog page in WordPress settings, but the page does not output list of posts, it just only outputs name of page "Herní články" and button read more (číst více) links to this page.. article id="post - id" showing classes "page type-page" and I really don't know how to resolve this problem..
The archive.php code is here:
<?php get_header(); ?>
<?php
$title_style = 'margin-bottom: 50px;';
$blog_content_style = 'margin-bottom: 30px;';
?>
<div id="primary" class="blog-content-area archive" style="<?php echo esc_attr($blog_content_style); ?>">
<?php
$title_color = (!empty($tdl_options['tdl_blog_title_color_scheme'])) ? $tdl_options['tdl_blog_title_color_scheme'] : 'mta-light';
$default_image_header = "";
if ( (isset($tdl_options['tdl_blog_default_header_bg']['url'])) && (trim($tdl_options['tdl_blog_default_header_bg']['url']) != "" ) ) {
$default_image_header = $tdl_options['tdl_blog_default_header_bg']['url'];
}
if ($default_image_header) {
$header_content_type = 'image';
$image_header = $default_image_header;
} else {
$header_content_type = '';
}
$title_align = $tdl_options['tdl_blog_title_align'];
?>
<?php
if ($header_content_type == 'image')
echo '<div class="site_header with_featured_img' . $no_parallax . '" style="' . $title_style . 'background-image:url(' . $image_header . ')">';
else
echo '<div class="site_header without_featured_img ' . $title_color . '" style="' . $title_style . '">';
?>
<div class="site_header_overlay"></div>
<div class="row">
<div class="large-12 <?php echo esc_attr( $title_align );?> large-centered columns">
<?php
if ((isset($tdl_options['tdl_shop_breadcrumb'])) && ($tdl_options['tdl_shop_breadcrumb'] == "1"))
{
// BREADCRUMBS
echo woodstock_breadcrumbs();
}
?>
<h1 class="page-title on-shop">
<?php
if ( is_category() ) :
single_cat_title();
elseif ( is_tag() ) :
single_tag_title();
elseif ( is_author() ) :
/* Queue the first post, that way we know
* what author we're dealing with (if that is the case).
*/
the_post();
printf( esc_html__( 'Author: %s', 'woodstock' ), '<span class="vcard">' . get_the_author() . '</span>' );
/* Since we called the_post() above, we need to
* rewind the loop back to the beginning that way
* we can run the loop properly, in full.
*/
rewind_posts();
elseif ( is_day() ) :
printf( esc_html__( 'Day: %s', 'woodstock' ), '<span>' . get_the_date() . '</span>' );
elseif ( is_month() ) :
printf( esc_html__( 'Month: %s', 'woodstock' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );
elseif ( is_year() ) :
printf( esc_html__( 'Year: %s', 'woodstock' ), '<span>' . get_the_date( 'Y' ) . '</span>' );
elseif ( is_tax( 'post_format', 'post-format-aside' ) ) :
esc_html_e( 'Asides', 'woodstock' );
elseif ( is_tax( 'post_format', 'post-format-image' ) ) :
esc_html_e( 'Images', 'woodstock');
elseif ( is_tax( 'post_format', 'post-format-video' ) ) :
esc_html_e( 'Videos', 'woodstock' );
elseif ( is_tax( 'post_format', 'post-format-quote' ) ) :
esc_html_e( 'Quotes', 'woodstock' );
elseif ( is_tax( 'post_format', 'post-format-link' ) ) :
esc_html_e( 'Links', 'woodstock' );
else :
esc_html_e( 'Archives', 'woodstock' );
endif;
?>
</h1>
<?php
// Show an optional term description.
$term_description = term_description();
if ( ! empty( $term_description ) ) :
printf( '<div class="term-description"><p>%s</p></div>', $term_description );
endif;
?>
</div><!-- .large-12 -->
</div><!-- .row -->
</div><!-- .site_header -->
<?php if ( $blog_with_sidebar == "yes" ) : ?>
<div class="row"><div class="large-8 columns with-sidebar">
<?php endif; ?>
<div id="content" class="site-content" role="main">
<?php if ( have_posts() ) : ?>
<!--masonry style-->
<?php if ( $blog_with_sidebar == "blog-masonry" ) : ?>
<div class="blog-isotop-master-wrapper">
<div class="row">
<div class="large-12 columns">
<div class="blog-isotop-container">
<div id="filters" class="button-group">
<button class="filter-item is-checked" data-filter="*">show all</button>
</div>
<div class="blog-isotope">
<div class="grid-sizer"></div>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="blog-post hidden <?php echo get_post_format(); ?>">
<div class="blog-post-inner">
<?php get_template_part( 'includes/content', get_post_format() ); ?>
<hr class="content_hr" />
</div><!--blog-post-inner-->
</div><!-- .blog-post-->
<?php endwhile; ?>
</div><!-- .blog-isotope -->
</div><!-- .blog-isotop-container-->
</div><!--.large-12-->
</div><!--.row-->
<?php woodstock_content_nav( 'nav-below' ); ?>
</div><!--blog-isotop-master-wrapper-->
<!--default style-->
<?php else : ?>
<?php if(is_author()) {
echo '<h1 class="author-name">Články od autora: '.get_the_author_meta('display_name', $author_id).'</h1>';
echo '<div class="author-description">'.get_the_author_meta('description', $author_id).'</div>';
} ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'includes/content', get_post_format() ); ?>
<hr class="content_hr" />
<?php endwhile; ?>
<?php woodstock_content_nav( 'nav-below' ); ?>
<?php endif; ?>
<!--no posts found-->
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</div><!-- #content -->
<?php if ( $blog_with_sidebar == "yes" ) : ?>
</div><!-- .columns -->
<?php endif; ?>
<?php if ( $blog_with_sidebar == "yes" ) : ?>
<div class="large-4 columns">
<div class="row">
<div class="large-10 large-push-2 columns">
<?php get_sidebar(); ?>
</div>
</div>
</div><!-- .columns -->
<?php endif; ?>
<?php if ( $blog_with_sidebar == "yes" ) : ?>
</div><!-- .row -->
<?php endif; ?>
<?php if ( $blog_with_sidebar == "yes" ) : ?>
<?php if (is_active_sidebar( 'sidebar')) : ?>
<div id="button_offcanvas_sidebar_left"><i class="sidebar-icon"></i></div>
<?php endif; ?>
<?php endif; ?>
</div><!-- #primary -->
<?php get_footer(); ?>
Same code works well on this URL
I've already tried update WordPress but it still doesn't work, so I'm helpless..
Problem was resolved by switching theme, so, it was maybe some bug in WP.
I need help in getting rid of a header in this code. It keeps adding a second header/banner to all pages except home.
I'm really not sure how to go about this. Below is the code, and the link to site is http://ultratest.com/ultratest/about-us/
Code on "banner.php"
<?php
/**
* Helper functions.
*
* #package Business_Kit
*/
if ( ( is_front_page()) || is_page_template( 'templates/home.php' ) ) {
return;
}
// Custom image.
$image_url = get_header_image();
if( !empty( $image_url ) ){
$banner_style = 'style="background: url('.esc_url( $image_url ).') top center no-repeat; background-size: cover;"';
} else{
$banner_style = '';
} ?>
<section id="featured-banner" class="overlay" <?php echo $banner_style; ?>>
<div class="container">
<div class="banner-title">
<?php
if(is_page() || is_single() ){ ?>
<h2><?php echo esc_html( get_the_title() ); ?></h2>
<?php
} elseif( is_search() ){ ?>
<h2><?php printf( esc_html__( 'Search Results for: %s', 'business-kit' ), '<span>' . get_search_query() . '</span>' ); ?></h2>
<?php
}elseif( is_404() ){ ?>
<h2><?php echo esc_html( 'Page Not Found: 404', 'business-kit'); ?></h2>
<?php
}elseif( is_home() ){ ?>
<h2><?php single_post_title(); ?></h2>
<?php
} else{
the_archive_title( '<h2>', '</h2>' );
}
?>
</div>
</div>
<?php get_template_part( 'template-parts/breadcrumbs' ); ?>
</section><!-- #main-banner -->
I have been trying to put the blog title below the blog post on my customised quark theme. However, everytime I do I get a blank blog post page (except header)
The code is:
<header class="entry-header">
<?php if ( is_single() ) { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php }
else { ?>
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
<?php } // is_single() ?>
<?php quark_posted_on(); ?>
<?php if ( has_post_thumbnail() && !is_search() ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to ', 'quark' ) . '%s', the_title_attribute( 'echo=0' ) ) ); ?>">
<?php the_post_thumbnail( 'post_feature_full_width' ); ?>
</a>
<?php } ?>
I change it to:
<header class="entry-header">
<?php } // is_single() ?>
<?php quark_posted_on(); ?>
<?php if ( has_post_thumbnail() && !is_search() ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to ', 'quark' ) . '%s', the_title_attribute( 'echo=0' ) ) ); ?>">
<?php the_post_thumbnail( 'post_feature_full_width' ); ?>
</a>
<?php if ( is_single() ) { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php }
else { ?>
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
<?php } ?>
I have also tried several variations of this with little success. I am sure I am being stupid, but any help would be great.
Thanks!
Try the following (based on my first answer and comments above):
<header class="entry-header">
<?php quark_posted_on(); ?>
<?php if ( has_post_thumbnail() && !is_search() ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( esc_html__( 'Permalink to ', 'quark' ) . '%s', the_title_attribute( 'echo=0' ) ) ); ?>">
<?php the_post_thumbnail( 'post_feature_full_width' ); ?>
</a>
<?php } ?>
<?php if ( is_single() ) { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php }
else { ?>
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
<?php } ?>
The second line may be causing issues unless there is a corresponding { somewhere above?
I set up a site for a photographer & she wanted to use her blog categories as her portfolio, which works fine, except for the fact that the infinite scrolling feature I'm using won't load all of the content for the excerpts.
The two items that it omits are the post thumbnail (image) and the horizontal row serving as a separator between the posts.
Any insight on this is appreciated - I'm using Paul Irish's infinite scroll plugin & the category excerpts are being called like so:
<?php get_header(); ?>
<section id="content" role="main">
<header class="header">
<h1 class="entry-title"><!-- <?php _e( 'Category Archives: ', 'themename' ); ?> --> <?php single_cat_title(); ?></h1>
<?php if ( '' != category_description() ) echo apply_filters( 'archive_meta', '<div class="archive-meta">' . category_description() . '</div>' ); ?>
</header>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?><div class="cat-thumbs align-right"><?php the_post_thumbnail(); ?></div>
<?php get_template_part( 'entry' ); ?>
<hr />
<?php endwhile; endif; ?>
<?php get_template_part( 'nav', 'below' ); ?>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
This is the entry template:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header>
<?php if ( is_singular() ) { echo '<h1 class="entry-title">'; } else { echo '<h2 class="entry-title">'; } ?><?php the_title(); ?><?php if ( is_singular() ) { echo '</h1>'; } else { echo '</h2>'; } ?><?php edit_post_link(); ?>
<?php if ( !is_search() ) get_template_part( 'entry', 'meta' ); ?>
</header>
<?php get_template_part( 'entry', ( is_archive() || is_search() ? 'summary' : 'content' ) ); ?>
<?php if ( !is_search() ) get_template_part( 'entry-footer' ); ?>
</article>
For reference, this is how I'm calling the excerpts for the blog, which have no issue:
<section class="entry-content">
<div class="cat-thumbs align-right"><?php the_post_thumbnail(); ?></div>
<?php the_excerpt(); ?>
<em><p>
<?php comments_number( '0 comments', '1 comment', '% comments' ); ?>.
</p></em>
<div class="entry-links"><?php wp_link_pages(); ?></div>
</section>
<hr />
Link to example
Move <div class="cat-thumbs align-right"><?php the_post_thumbnail(); ?></div> and <hr> into the entry template.
Im having an issue with a theme i've been customizing. My blog post only shows ( 1 ) post and i cant seem to fix the issue in Admin > Reading > Blog pages show at most. The Value only stays at "1" even after save. The code i have here is in the Loop.php
<?php ?>
<article class="primary-content">
<?php $firstClass='first-post' ; ?>
<?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if ( ! have_posts() ) : ?>
<article role="main" class="the-content">
<h1><?php _e( '404 - I'm sorry but the page can't be found' ); ?></h1>
<p>Please try searching again or head back to the homepage.</p>
</article>
<?php endif; ?>
<?php ?>
<?php if (is_home()): ?>
<h1>
<?php if ( is_day() ) : ?><?php printf( __( '<span>Daily Archive</span> %s' ), get_the_date() ); ?>
<?php elseif ( is_month() ) : ?><?php printf( __( '<span>Monthly Archive</span> %s' ), get_the_date('F Y') ); ?>
<?php elseif ( is_year() ) : ?><?php printf( __( '<span>Yearly Archive</span> %s' ), get_the_date('Y') ); ?>
<?php elseif ( is_category() ) : ?><?php echo single_cat_title(); ?>
<?php elseif ( is_search() ) : ?><?php printf( __( 'Search Results for: %s' ), '<span>' . get_search_query() . '</span>' ); ?>
<?php elseif ( is_home() ) : ?>Blog<?php else : ?>
<?php endif; ?>
</h1>
<?php endif; ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php /* How to display standard posts and search results */ ?>
<article class="article-archive <?php echo $firstClass; ?>" id="post-<?php the_ID(); ?>">
<?php $firstClass="" ; ?>
<?php ?>
<?php if (is_front_page()) { ?>
<div class="home-summary">
<?php } else { ?>
<div class="entry-summary">
<?php } ?>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( '%s' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php the_post_thumbnail( 'flozo-thumb');?>
</a>
<?php if (is_front_page()) { ?>
<h1><?php the_title(); ?></h1>
<?php } else { ?>
<h2><?php the_title(); ?></h2>
<?php } ?>
<?php the_excerpt(); ?>
<?php if ( is_home() ) : ?>
<p class="entry-meta">
<time datetime="<?php the_time('l, F jS, Y') ?>" pubdate>
<?php the_time( 'l jS F Y') ?>
</time>
</p>
<?php endif; ?>
</div>
</article>
<?php /*?>
<?php comments_template( '', true ); ?>
<?php */?>
<?php endwhile; // End the loop. Whew. ?>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div class="navigation">
<div class="nav-previous">
<?php next_posts_link( __( 'Older posts' ) ); ?>
</div>
<div class="nav-next">
<?php previous_posts_link( __( 'Newer posts' ) ); ?>
</div>
</div>
<!-- #nav-below -->
<?php endif; ?>
</article>
Any and all help with be greatly appreciated! Sorry if this was posted already.
L