I am pretty new in WordPress and I have the following doubt about how link a CSS file into a WP theme.
For example this is the header.php file of the TwentyTwelve preinstalled template:
<?php
/**
* The Header template for our theme
*
* Displays all of the <head> section and everything up till <div id="main">
*
* #package WordPress
* #subpackage Twenty_Twelve
* #since Twenty Twelve 1.0
*/
?><!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">
<hgroup>
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
</hgroup>
<nav id="site-navigation" class="main-navigation" role="navigation">
<h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav><!-- #site-navigation -->
<?php if ( get_header_image() ) : ?>
<img src="<?php header_image(); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
<?php endif; ?>
</header><!-- #masthead -->
<div id="main" class="wrapper">
This file start with the beginning tag but I can't see the link to the used style.css file. Where is it?
Tnx
Andrea
You should check functions.php file in your theme folder:
function twentytwelve_scripts_styles() {
.....
/*
* Loads our main stylesheet.
*/
wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() );
......
}
add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' );
You can find more info about including styles and scripts in your wordpress site on this links:
http://codex.wordpress.org/Function_Reference/wp_enqueue_style
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
if you want to edit .css file, you can find it at wordpress theme folder.
this is default path:
wp-content\themes
Related
Okay I have no idea why wordpress is not rendering html, just a blank screen. Checking inspect element and I can't see the html structure of the website.
I assume the problem could be with the header however I've double checked for errors not sure. The title name on the window tab screen isn't even showing.
Any ideas: here is a link too: https://www.radian3.com
Here is the header.php
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <div id="main">
*
* #package Shape
* #since Shape 2.0
*/
?><!DOCTYPE html>
<!--[if IE 8]>
<html id="ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<title><?php
/*
* Print the <title> tag based on what is being viewed.
*/
global $page, $paged;
wp_title( '|', true, 'right' );
// Add the blog name.
bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'shape' ), max( $paged, $page ) );
?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<!-- This part loads a JavaScript file that enables old versions of Internet Explorer to recognize the new HTML5 elements, and it only loads for visitors who are using IE 8 or earlier. -->
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">
<hgroup>
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
</hgroup>
<nav role="navigation" class="site-navigation main-navigation">
<!-- add a skip link so folks using a screen reader don’t have to suffer through our menu when they just want to get to the content. -->
<h1 class="assistive-text"><?php _e( 'Menu', 'playTheme' ); ?></h1>
<div class="assistive-text skip-link"><?php _e( 'Skip to content', 'playTheme' ); ?></div>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
</nav><!-- .site-navigation .main-navigation -->
</header><!-- #masthead .site-header -->
<div
id="main" class="site-main">
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.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* #package Shape
* #since Shape 1.0
*/
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<script type="text/javascript"> alert("asdasdsa");</script>
</div><!-- #content .site-content -->
</div><!-- #primary .content-area -->
<div>
asldjaslkdj
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
For some reason my contact form is showing up above my wordpress header as shown below:
Here is my code:
<?php
/**
* Template Name: Contact Us
*
* #package WordPress
* #subpackage Creativeforces
* #since Creativeforces Group 1.0
*/
?>
<head>
<meta charset="utf-8">
<title>Creative Forces | Contact Us</title>
<link rel="stylesheet" type="text/css" href="/wp-content/themes/creativeforces/css/contact.css">
<link href='https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700' rel='stylesheet' type='text/css'>
</head>
<header>
<?php while ( have_posts() ) : the_post() ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php get_sidebar(); ?>
</header>
<?php get_header(); ?>
<?php get_footer(); ?>
and on the contact page in wordpress admin I have the shortcode:
[contact-form-7 id="131" title="Contact form 1"]
here is header.php id needed:
<?php
/**
* The template for displaying the header
*
* Displays all of the head element and everything up until the "site-content" div.
*
* #package WordPress
* #subpackage Creativeforces
* #since Creativeforces 1.0
*/
?>
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<?php wp_head(); ?>
<link rel="alternate" type="application/rss+xml" href="<?php bloginfo('rss2_url'); ?>" title="<?php printf( __( '%s latest posts', 'your-theme' ), wp_specialchars( get_bloginfo('name'), 1 ) ); ?>" />
<link rel="alternate" type="application/rss+xml" href="<?php bloginfo('comments_rss2_url') ?>" title="<?php printf( __( '%s latest comments', 'your-theme' ), wp_specialchars( get_bloginfo('name'), 1 ) ); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
</head>
<body data-spy="scroll" data-target=".navbar">
<div class="black-line"></div>
<!-- LOGO -->
<?php if ( get_theme_mod( 'themeslug_logo' ) ) : ?>
<div class='site-logo'>
<a href='<?php echo esc_url( home_url( '/' ) ); ?>' title='<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>' rel='home'><img src='<?php echo esc_url( get_theme_mod( 'themeslug_logo' ) ); ?>' alt='<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>'></a>
</div>
<?php else : ?>
<!-- Displayes blog title and description -->
<hgroup>
<h1 class='site-title'><a href='<?php echo esc_url( home_url( '/' ) ); ?>' title='<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>' rel='home'><?php bloginfo( 'name' ); ?></a></h1>
<h2 class='site-description'><?php bloginfo( 'description' ); ?></h2>
</hgroup>
<?php endif; ?>
<!-- Top-Nav-Menu -->
<div id="menu" class="navbar text-center">
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header', 'container' => 'nav', 'theme_location' => 'header-menu', 'walker' => new wp_bootstrap_navwalker()) ); ?>
</div>
any help would be appreciated!
You have placed wp_header() after the the_content()
It should next to tag.
Generally It is like -
- header
- content
- footer
Here is the code after modification -
<?php
/**
* Template Name: Contact Us
*
* #package WordPress
* #subpackage Creativeforces
* #since Creativeforces Group 1.0
*/
?>
<head>
<meta charset="utf-8">
<title>Creative Forces | Contact Us</title>
<link rel="stylesheet" type="text/css" href="/wp-content/themes/creativeforces/css/contact.css">
<link href='https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<header>
<?php get_header(); ?>
</header>
<?php while ( have_posts() ) : the_post() ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php get_sidebar(); ?>
<footer>
<?php get_footer(); ?>
</footer>
You are adding content/sidebar inside header section and after that this header has been added so that's the reason your contact form 7 is appearing above the header.
Please try like this
<header>
<?php get_header(); ?>
</header>
<div class="contentdiv">
<?php while ( have_posts() ) : the_post() ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php get_sidebar(); ?>
</div>
I am a beginner in WP. I want different logo in each page of word press site like for few page of the site i need different logo and different for other. i tried to use conditional statement but as i am beginner so my overall site crashes and have a blank screen. if there is some plugin that can achieve this kind of functionality it would be really a great help.
Can you guide me how to achieve it.
Here is my header.php code i tried to edit it but all in vain.
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<meta name="viewport" content="initial-scale=1">
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/source/vendor/html5.js" type="text/javascript"></script>
<![endif]-->
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">
<div class="container">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home" class="site-branding">
<!--Editing start from here and i am gona delete all other code from above span section-->
<?php $header_image = get_header_image(); ?>
<h1 class="site-title">
<?php if ( ! empty( $header_image ) ) : ?>
<img src="<?php echo $header_image ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
<?php endif; ?>
<span><?php bloginfo( 'name' ); ?></span>
</h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
</a>
<nav id="site-navigation" class="site-primary-navigation slide-left">
<i class="icon-cancel-circled"></i> <span><?php _e( 'Close', 'jobify' ); ?></span>
<?php get_search_form(); ?>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu-primary' ) ); ?>
</nav>
<?php if ( has_nav_menu( 'primary' ) ) : ?>
<i class="icon-menu"></i>
<?php endif; ?>
</div>
</header><!-- #masthead -->
<div id="main" class="site-main">
Thanks
Try using something like this.
if(is_page('Blog')){ // the parameter used here is the post_title
echo '<img src="http://yourwebsite.com/path-to-your-image/blog-logo.png" />';
}elseif(is_page('home')){ // the parameter used here is the post slug
echo '<img src="http://yourwebsite.com/path-to-your-image/home-logo.png" />';
}elseif(is_page('42')){ // the parameter used here is the post id
echo '<img src="http://yourwebsite.com/path-to-your-image/other-logo.png" />';
}else{ // else display default logo
$header_image = get_header_image();
}
You can get more info here:
https://codex.wordpress.org/Function_Reference/is_page
Depending on the theme you are using, it's sometimes build-in feature!
I know Arcade Basic which has this custom header feature:
https://wordpress.org/themes/arcade-basic/
There are probably much more theme's which supports this feature by default, search on the 'featured-image-header' and 'flexible-header' tags on the Wordpress site to find more themes....
https://wordpress.org/themes/tags/featured-image-header/
https://wordpress.org/themes/tags/flexible-header/
And maybe 'custom-header' tag?
https://wordpress.org/themes/tags/custom-header/
Finally, there are indeed a lot of plugins, like "WP Header Images", more can be found here:
https://wordpress.org/plugins/search.php?q=header+image&sort=
I've removed the Search function from the theme 'Corporate' (by WP Explorer), I've deleted Search.php Searchform.php, search from CSS and also Search from the Header file, however the area where search was is now clickable, linking to homepage.
Header info below:
<?php
/**
* The Header for our theme.
*
* #package WordPress
* #subpackage Corporate WPExplorer Theme
* #since Corporate 1.0
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width">
<title><?php wp_title( '|', true, 'right' ); ?><?php bloginfo('name'); ?></title>
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php if ( get_theme_mod('wpex_custom_favicon') ) { ?>
<link rel="shortcut icon" href="<?php echo get_theme_mod('wpex_custom_favicon'); ?>" />
<?php } ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>
<![endif]-->
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="wrap" class="clr container">
<div id="header-wrap" class="clr">
<header id="header" class="site-header clr" role="banner">
<?php
// Outputs the site logo
// See functions/logo.php
wpex_logo(); ?>
<!-- Search removed from here -->
</header><!-- #header -->
</div><!-- #header-wrap -->
<div id="sidr-close"></div>
<div id="site-navigation-wrap">
<span class="fa fa-bars"></span><?php echo __( 'Menu', 'wpex' ); ?>
<nav id="site-navigation" class="navigation main-navigation clr" role="navigation">
<?php
// Display main menu
wp_nav_menu( array(
'theme_location' => 'main_menu',
'sort_column' => 'menu_order',
'menu_class' => 'dropdown-menu sf-menu',
'fallback_cb' => false
) ); ?>
</nav><!-- #site-navigation -->
</div><!-- #site-navigation-wrap -->
<div id="main" class="site-main clr">
Add the search div back, but only remove the code within the div. By removing the div, you removed the space that it was taking up and the logo's clickable area was extended to be wider. Removing it fully will require some CSS edits.
I want to hide the default Wordpress home page from my website navigation
http://www.dawaf.co.uk/es/portraits
I am using Twenty Eleven as the parent theme but I was wondering whether it was possible to do this using CSS rather than editing the header.php which doesn't seem to work when I remove any reference to 'home'
header.php
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <div id="main">
*
* #package WordPress
* #subpackage Twenty_Eleven
* #since Twenty Eleven 1.0
*/
?><!DOCTYPE html>
<!--[if IE 6]>
<html id="ie6" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 7]>
<html id="ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html id="ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php
/* We add some JavaScript to pages with the comment form
* to support sites with threaded comments (when in use).
*/
if ( is_singular() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
/* Always have wp_head() just before the closing </head>
* tag of your theme, or you will break many plugins, which
* generally use this hook to add elements to <head> such
* as styles, scripts, and meta tags.
*/
wp_head();
?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed">
<header id="branding" role="banner">
<div class="site-title"><img src="http://www.dawaf.co.uk/es/wp-content/themes/child/images/photosdirector.png"></div>
<?php
// Check to see if the header image has been removed
$header_image = get_header_image();
if ( ! empty( $header_image ) ) :
?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
// The header image
// Check if this is a post or page, if it has a thumbnail, and if it's a big one
if ( is_singular() &&
has_post_thumbnail( $post->ID ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) &&
$image[1] >= HEADER_IMAGE_WIDTH ) :
// Houston, we have a new header image!
echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
else : ?>
<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
<?php endif; // end check for featured image or standard header ?>
</a>
<?php endif; // end check for removed header image ?>
<?php
// Has the text been hidden?
if ( 'blank' == get_header_textcolor() ) :
?>
<div class="only-search<?php if ( ! empty( $header_image ) ) : ?> with-image<?php endif; ?>">
<?php get_search_form(); ?>
</div>
<?php
else :
?>
<?php get_search_form(); ?>
<?php endif; ?>
<nav id="access" role="navigation">
<h3 class="assistive-text"><?php _e( 'Main menu', 'twentyeleven' ); ?></h3>
<?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?>
<div class="skip-link"><a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to primary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to primary content', 'twentyeleven' ); ?></a></div>
<div class="skip-link"><a class="assistive-text" href="#secondary" title="<?php esc_attr_e( 'Skip to secondary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to secondary content', 'twentyeleven' ); ?></a></div>
<?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
</nav><!-- #access -->
</header><!-- #branding -->
<div id="main">
Your header.php is loading the menu dynamically from the Wordpress dashboard. Edit the menu here: Dashboard > Appearance > Menus