How to reduce the Home link size in my header? - php

I'm playing with html and css to make the home link of my header covering only the left half of the header size. Each time I'm resizing the Home Link, it changes my header size. I thought it was because they're in the same div so I put the
<img class="header-logo"...</>
above the
<a class="home-link"...</a>
and put it in its own div and gave a brand new id to the logo. Unfortunately that made my header wider which I don't want to. How would you proceed to reduce the homelink size?
I'm using Wordpress and its twentythirteen default theme.
<header id="masthead" class="site-header" role="banner">
<a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<img class="header-logo" src="http://localhost/test/wp-content/themes/twentythirteen-child/resources/logo_big2_v2.png" />
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
</a>
Here is a sample of the related CSS:
.site-header {
margin:10px auto 0 auto;
max-width:980px;
padding:0;
background-size: 980px auto;
}
.site-header .home-link {
min-height: 50px;
}
.header-logo {
max-width:60%;
display:block;
padding-top:3px;
padding-bottom:5px;
position:relative;
}

header logo,title and description are all nested inside the .home-link. So changing the homelinks will have impact on the child classes.You might try the code below where you can style individual classes without affecting the other classes.
<a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"></a>
<img class="header-logo" src="http://localhost/test/wp-content/themes/twentythirteen-child/resources/logo_big2_v2.png" />
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>

Why do you put so many classes in your html : why not
<header id="masthead" class="site-header" role="banner">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<img src="http://localhost/test/wp-content/themes/twentythirteen-child/resources/logo_big2_v2.png" />
<h1><?php bloginfo( 'name' ); ?></h1>
<h2><?php bloginfo( 'description' ); ?></h2>
</a>
then
/* css */
.site-header {
margin:10px auto 0 auto;
/* max-width:980px; not needed : the visitor's choice...*/
padding:0;
background-size: 980px auto;
}
.site-header > a {
min-height: 50px;
width : 50%; /* site header link will cover only
a half of the header, the containing div */
}
.site-header > img {
max-width:60%;
display:block;
padding-top:3px;
padding-bottom:5px;
position:relative;
}

This is what I used in the end:
<a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<img class="header-logo" src="http://localhost/test/wp-content/themes/twentythirteen-child/resources/logo_big2_v2.png" /></a>
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
and
.site-header .home-link {
min-height: 169px;
max-width:50%;
position:static;
left:-250px;
}
Now everything seems OK, but not exactly, the responsiveness is broken and the menu is not resizing at low screen resolution because of the min-height: 169px; CSS property that I need otherwise the logo is out of the header section. One problem solved, here comes a new one. Edit: I still haven't figured out a solution for this.

Related

How do I place my background color at the bottom of my content's container?

I would like to apply a background color, with a height of 200px. I would then like to position this background colour at the bottom of the concerned content. I have managed to achieve this across the other web pages I am working on but struggling with this page. No matter what I do, the background colour stays at the top of the content's container.
HTML/PHP:
<div class="row" id="latest-products">
<h2 id="latest-products-title-row"><i class="fa fa-dot-circle-o fa-rotate-270" aria-hidden="true"></i><span id="latest-products-title">Latest Products</span><i class="fa fa-dot-circle-o fa-rotate-270" aria-hidden="true"></i></h2>
<ul class="row-fluid">
<?php
$args = array( 'post_type' => 'product', 'stock' => 1, 'posts_per_page' => 4, 'orderby' =>'date','order' => 'DESC' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product;
?>
<li class="latest-products-content">
<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php
if (has_post_thumbnail( $loop->post->ID ))
echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="65px" height="115px" />';
?>
</a>
<h3><?php the_title(); ?></h3>
<p><?php the_excerpt(); ?></p>
<div class="price"><i class="fa fa fa-dot-circle-o fa-rotate-270" aria-hidden="true"></i><span id="product-price"><?php echo $product->get_price_html(); ?></span><i class="fa fa-dot-circle-o fa-rotate-270" aria-hidden="true"></i></div>
<div class="view/buy"><a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">View/Buy</a></div>
</li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
</div>
CSS
#latest-products{
background-color: blue;
height: 200px;
background-position: bottom;
}
Any suggestions on where I could be going wrong here, would be appreciated.
To use background position property you need to set background-image, so to fill bottom 200px area with color you can set following:
background-image: linear-gradient(blue, blue 100%);
background-size: 100% 200px;
background-repeat: no-repeat;
background-position: center bottom;
If you inspect the script with your browser, you will see that #latest-products is completely filled with the blue color. This is because background-position is only for background-image. It does not provide you any offset to just a color.
The background-position property sets the starting position of a background image.
Source: https://www.w3schools.com/cssref/pr_background-position.asp
You can create an other div, which is positioned absolute at the bottom of #latest-products. This might solve your problem.

How to make responsive wordpress theme when zooming and compatible with Internet Explorer/Edge?

I have a problem when making a wordpress theme cannot responsive when zooming and open on Internet Explorer/Edge and got worst result after tested on many devices like screenshot below:
Cannot compatible with IE/Edge:
Cannot responsive when zooming:
Index.php
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* #link https://codex.wordpress.org/Template_Hierarchy
*
* #package test
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php if ( is_home() && ! is_front_page() ) : ?>
<header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header>
<?php endif; ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', get_post_format() );
?>
<?php endwhile; ?>
<?php the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Header.php
<?php
/**
* The header for our theme.
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* #link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* #package test
*/
global $woocommerce;
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="container">
<div id="page" class="hfeed site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'gg' ); ?></a>
<header id="masthead" class="site-header" role="banner">
<nav id="site-navigation" class="main-navigation2" role="navigation">
<button class="menu-toggle" aria-controls="top-menu" aria-expanded="false"><?php esc_html_e( 'Top Menu', 'gg' ); ?></button>
<ul class="mini-cart">
<li> <a href="<?php echo esc_url( $woocommerce->cart->get_cart_url() ); ?>" title="<?php esc_attr_e('View your shopping cart'); ?>" class="cart-parent">
<div class="bubblex">
<div class="inside">
<div class="inside-text">
<?php
echo sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count), $woocommerce->cart->cart_contents_count);
?></div>
</div>
</div>
<i class="cart_control">::before</i></a>
<?php
echo '<ul class="cart_list">';
echo '<li class="cart-title"><b>Isi Keranjang:</b></li>';
if (sizeof($woocommerce->cart->cart_contents)>0) : foreach ($woocommerce->cart->cart_contents as $cart_item_key => $cart_item) :
$_product = $cart_item['data'];
if ($_product->exists() && $cart_item['quantity']>0) :
echo '<li class="cart_list_product"><a href="' . esc_url( get_permalink( intval( $cart_item['product_id'] ) ) ) . '">';
/* echo $_product->get_image(); */
echo apply_filters( 'woocommerce_cart_widget_product_title', $_product->get_title(), $_product ) . '</a>';
if($_product instanceof woocommerce_product_variation && is_array($cart_item['variation'])) :
echo woocommerce_get_formatted_variation( $cart_item['variation'] );
endif;
echo '<span class="quantity">' . $cart_item['quantity'] . ' × ' . woocommerce_price( $_product->get_price() ) . '</span></li>';
endif;
endforeach;
else: echo '<li class="empty">' . __( 'Keranjang kosong') . '</li>'; endif;
if ( sizeof( $woocommerce->cart->cart_contents ) > 0 ) :
echo '<li class="total">';
echo '<span class="amount2">Subtotal</span>' . $woocommerce->cart->get_cart_total() . '</li>';
echo '<p class="buttons">Detail Checkout</p>';
endif;
echo '</ul>';
?>
</li> </ul>
<?php wp_nav_menu( array( 'theme_location' => 'top', 'menu_id' => 'top-menu' ) ); ?>
</nav><!-- #site-navigation -->
<div class="site-branding">
<?php if ( is_front_page() && is_home() ) : ?>
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<?php else : ?>
<p class="site-title"><?php bloginfo( 'name' ); ?></p>
<?php endif; ?>
<p class="site-description"><?php bloginfo( 'description' ); ?></p>
</div><!-- .site-branding -->
<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( 'Primary Menu', 'gg' ); ?></button>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_id' => 'primary-menu' ) ); ?>
</nav><!-- #site-navigation -->
</div><!-- #site-wrapper -->
</header><!-- #masthead -->
<div id="content" class="site-content">
Style.css
body {
/* margin: 0 170px 0 20px; */
max-width: 100%;
background: #fff;
margin-left: auto;
margin-right: auto;
}
body {
background-image: url('img/background.png');
background-size: 960px 1600px;
background-repeat: no-repeat;
background-position: top center;
background-attachment: scroll;
}
#media only screen and (max-width: 1200px)
#content {
background-color: #FFFFFF;
}
site-content {
margin: 107px 23.5%;
}
.main-navigation2 {
float: none;
height: 59px;
margin: -18px 196px;
font-size: 12px;
/* font-style: normal; */
}
For further information please check out on development link.
So how I can fix it?
Apply some global styles without media queries then work backwards depending on resolution needs with media queries.
I made some minor changes to your css while viewing in 1200 wide and it fixed the menu issue perfectly. When zooming, it defaulted to the relevant media query.
.main-navigation {
width: 960px;
margin: auto;
}
.menu-primary-menu-container {
margin: 0 0 0 200px;
float: right;
}
ul#primary-menu {
margin: 0px;
}
.main-navigation li {
float: left;
}
.main-navigation a {
padding: 4px 29px 0 16px;
display: block;
text-decoration: none;
/* line-height: 50px; */
color: #000;
font-family: sans-serif;
font-weight: bold;
font-size: small;
}
Bootstrap is a better approach, but I see you've already put some fair amount of work into this theme. This might not be a complete solution, but in theory if you make some minor adjustments as I did below, you can then adjust them as needed for varying viewport sizes in CSS media query.

Finding DIV's in a php | Wordpress

i am trying to findout, in which php file does the below exists.
Reason, the href does not work on the logo1.png. in my below code.
<div class="site-branding">
<h1 class="site-title">IRONWARE</h1>
<p class="site-description">Home Products..</p>
</div>
stylesheet:
.site-branding {
content: url("http://ironware.in/wp-content/uploads/2015/07/Logo1.png");
width: 35% !important;
Now to find, by browser > right click > Inspect element > in which PHP does the exists ?
I found the solution by adding the below to my childs theme's header.php
add_action( 'init', 'storefront_custom_logo' );
function storefront_custom_logo() {
remove_action( 'storefront_header', 'storefront_site_branding', 20 );
add_action( 'storefront_header', 'storefront_display_custom_logo', 20 );
}
function storefront_display_custom_logo() {
?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="site-logo-link" rel="home">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/logo.png" alt="<?php echo get_bloginfo( 'name' ); ?>" />
</a>
<?php
}

Wordpress - how to remove header [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I added a Wordpress blog on a website. This is how it looks so far: http://alweso.2ap.pl/blog/?m=201403
I would like to get rid of the header area - for the menu to be on top, so it resembles the non-Wordpress pages. I'm a complete newbie if it comes to PHP - what should I remove or add? I'm guessing I should play with header.php, so here's the code:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php wp_title(); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_head(); ?>
</head>
<body <?php body_class() ?>>
<div id="wrapper">
<header id="header">
<<?php pinboard_title_tag( 'site' ); ?> id="site-title">
<?php if ( ( '' != get_header_image() ) && ( false != get_header_image() ) ) : ?>
<a href="<?php echo home_url( '/' ); ?>" rel="home">
<img src="<?php header_image(); ?>" alt="<?php bloginfo( 'name' ); ?>" width="<?php echo ( pinboard_get_option( 'retina_header' ) ? absint( get_custom_header()->width / 2 ) : get_custom_header()->width ); ?>" height="<?php echo ( pinboard_get_option( 'retina_header' ) ? absint( get_custom_header()->height / 2 ) : get_custom_header()->height ); ?>" />
</a>
<?php endif; ?>
<a class="home" href="<?php echo home_url( '/' ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
</<?php pinboard_title_tag( 'site' ); ?>>
<?php if( ! is_active_sidebar( 1 ) ) : ?>
<<?php pinboard_title_tag( 'desc' ); ?> id="site-description"><?php bloginfo( 'description' ); ?></<?php pinboard_title_tag( 'desc' ); ?>>
<?php endif; ?>
<?php get_sidebar( 'header' ); ?>
<div class="clear"></div>
<nav id="access">
<a class="nav-show" href="#access">Show Navigation</a>
<a class="nav-hide" href="#nogo">Hide Navigation</a>
<?php wp_nav_menu( array( 'theme_location' => 'primary_nav' ) ); ?>
<div class="clear"></div>
</nav><!-- #access -->
</header><!-- #header -->
<?php wp_nav_menu( array( 'theme_location' => 'primary_nav' ) ); ?>
This function showing your nav menu, show you have to call this function , wherever you want to show the menu.
with CSS it can be done, in your style.css (/blog/wp-content/themes/pinboard/style.css)
ADD change next:
#site-title {
margin: 0 3.4%;
font-family: "Oswald", sans-serif;
font-size: 32px;
letter-spacing: 1px;
}
into:
#site-title {
margin: 0 3.4%;
font-family: "Oswald", sans-serif;
font-size: 32px;
letter-spacing: 1px;
visibility: hidden;
height: 0px;
}
and:
#site-title, #site-description {
margin: 0;
font-weight: 300;
float: left;
line-height: 150px;
}
into:
#site-title, #site-description {
margin: 0;
font-weight: 300;
float: left;
line-height: 150px;
visibility: hidden;
height: 0px;
}
and:
#header #searchform {
float: right;
margin: 60px 3.4% 0 3px;
}
into:
#header #searchform {
visibility: hidden;
}
it will give this result:

Changing the header of the bliss wordpress template

I have this wordpress template: http://bluth.is/wordpress/bliss/
and I want to change the header. The subtitle should be UNDER the logo and not next to it. I have tried to make the content bigger and the logo smaller but nothing works. Any ideas?
The Code from the header.php:
<div class="span9" style="height:90px;">
<p>
<a class="brand brand-image" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img src="<?php echo $logo; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"><?php if(!of_get_option('disable_description')){ ?></a>
</p>
<small><?php bloginfo( 'description' ); ?></small></div><?php } ?>
Using CSS margin you can move it wherever you want.
I don't know exactly the using pixles but here is how it suppose to be:
margin: 30px -100px 0;
Ofcourse there is a better way using photoshop to edit the logo and add him this subtitle.

Categories