I'm quite new to WP, and am trying to learn some HTML5/CSS/PHP while using it. Currently I'm having some troubles.
I created a custom page (to have just a clean blank page without the header etc...) and I also created a Contact Form 7 that should be responsive..
However this doesn't work. When I load it on mobile, it does not adjust.
This is the code for the template page:
<?php
/**
* Template Name: Blank Page Header
*
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<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' ); ?>">
<div id="logo2" align="center"><img src="http://adventoury.com/wp-content/uploads/2017/04/IMG_20160507_153704_HDR-Recoveredcropped2.jpg" width="100%" ></div>
<br>
<!-- page title, displayed in your browser bar -->
<title><?php bloginfo('name'); ?> | <?php is_home() ? bloginfo('description') : wp_title(''); ?></title>
<!-- add feeds, pingback and stuff-->
<link rel="profile" href="http://gmpg.org/xfn/11" />
<?php wp_head(); ?>
</head>
<body id="top">
<div class='container_wrap' id='main'>
<div class='container'>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php get_template_part('page-parts/general-after-wrap'); ?>
<?php wp_footer(); ?>
</body>
</html>
And this is the CSS to make my from responsive
#media only screen and (min-width: 48em) {
.column-half{
width: 50%;
}
}
Am I missing something?
Kind regards!
You just need to add this code for template
<?php
/**
* Template Name: Blank Page Header
*
*/
get_header();
?>
<div class='container_wrap' id='main'>
<div class='container'>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php get_template_part('page-parts/general-after-wrap'); ?>
<?php get_footer(); ?>
Related
How to create multiple headers in Wordpress? My file includes footer.php, footer-login.php, functions.php, header.php, header-login.php, index.php and page.php.
In my header-login.php file,
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>??????</title>
<script src='https://www.google.com/recaptcha/api.js'></script>
<meta http-equiv="Cache-Control" content="max-age=8640000" />
<?php wp_head();?>
</head>
<body>
For my index.php,
<?php get_header(); ?>
<div id="main">
<div id="content">
<p><?php if (have_posts()) : while (have_posts()) : the_post(); ?></p>
<p><?php the_content(__('(more...)')); ?></p>
<p><?php endwhile; else: ?></p>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<p><?php endif; ?></p>
</div>
</div>
<?php get_footer(); ?>
Page.php
<?php
if(is_page(2)) {
get_header('login');
} else {
get_header();
}
wp_head();
?>
Why can I still get the blank page when I open the website?
Result
File/Folder
<!--functions.php-->
<?php
function learningWordPress_resources() {
wp_enqueue_style('style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts', 'learningWordPress_resources');
I get the message "class="home blog logged-in admin-bar no-customize-support">" below my navigation bar in the wordpress I am coding from scratch. Does anyone know how to remove this? If so, your help would be much appreciated : )
(The attached code won't run here because it's dependent on wordpress. Hopefully, the attached picture is enough to explain the situation)
/*
CSS:
Theme Name: Yonsei Fencing
Author: Yonsei Student
Version: 1.0
*/
<!--index.php-->
<?php
get_header();
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile;
else:
echo '<p>No content found</p>';
endif;
get_footer();
?>
<!--header.php-->
<!DOCTYPE html>
<html> <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width">
<title><?php bloginfo('name'); ?></title>
<?php wp_head(); ?>
</head>
<body> <?php body_class(); ?>>
<!--site-header-->
<header class="site-header">
<h1><?php bloginfo('name'); ?></h1>
<h5><?php bloginfo('description'); ?></h5>
</header><!--/site-header-->
<!--footer.php-->
<footer class="site-footer">
<p><?php bloginfo('name'); ?> - © <?php echo date('Y');?></p>
</footer>
<?php wp_footer(); ?>
</body>
</html>
The issue is that the function body_class() belongs inside your body tag, but in the code you've posted, it's after the body tag.
Change your code as follows, and you're good to go:
FROM this, which closes the body tag first:
<body> <?php body_class(); ?>>
TO this, which contains the body_class inside the body tag:
<body <?php body_class(); ?>>
So, I'm working on my website, in Wordpress. To say on the beggining, I'm no php coder, I just stambled on this thing working on my wordpress website. I bought a theme and installed Simple Language Switcher plugin. It works but I don't know how to place it where I want. I tried it everywhere in my header.php file but no luck. You can see in the image below where it is right now and where I want it (right, where I wrote HERE). And the link for the plugin:
http://www.mendoweb.be/blog/wordpress-plugin-simple-language-switcher/
This is the code for my language bar:
<?php if( function_exists( 'simple_language_switcher' ) ) { ?>
<div id="simple-language-switcher"><?php simple_language_switcher(); ?></div>
<?php } ?>
Here's my header.php file right now:
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <main id="main">
*
* #package Terrifico
*/
?><!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>
<?php global $data; ?>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php if ($data['enable_favicon'] == 1 ) { ?>
<link rel="shortcut icon" href="<?php echo $data['favicon']; ?>" type="image/x-icon" />
<?php } ?>
<?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 terrifico_custom_styling(); ?>
<?php wp_head(); ?>
<?php if ($data['custom_css'] <> "") { ?>
<style type="text/css">
<?php echo $data['custom_css']; ?>
</style>
<?php } ?>
</head>
<body <?php body_class(); ?>>
<div id="grid-container">
<?php if ( $data['top_panel_enable'] == 1 ) { get_template_part( 'top-panel' ); }; ?>
<?php if( function_exists( 'simple_language_switcher' ) ) { ?>
<div id="simple-language-switcher"><?php simple_language_switcher(); ?></div>
<?php } ?>
<div class="clear"></div>
<div id="branding" class="<?php echo $data['layout']; ?>">
<header id="header">
<div id="logo">
<?php if ( $data['text_logo_enable'] != 1 ) { ?>
<img src="<?php echo $data['logo']; ?>" alt="<?php echo $data['logo_alt_text']; ?>"/>
<?php } else { ?>
<?php echo $data['logo_alt_text']; ?>
<?php } ?>
</div>
<?php if ( $data['menu_separated'] != 1 ) { ?>
<div id="nav-holder">
<nav id="site-navigation-in" class="main-navigation" role="navigation">
<?php wp_nav_menu(array('theme_location' => 'main_navigation', 'container' => false,'menu_id'=>'menu-main-navigation','menu_class' => 'sf-menu sf-js-enabled sf-shadow', 'fallback_cb'=> 'terrifico_selectmenu', )); ?>
</nav><!--site-navigation-->
</div>
<?php } ?>
<script type="text/javascript">
var sf=jQuery.noConflict();
sf(window).load(function(){
// superFish
sf('ul.sf-menu').supersubs({
minWidth: 16, // minimum width of sub-menus in em units
maxWidth: 40, // maximum width of sub-menus in em units
extraWidth: 1 // extra width can ensure lines don't sometimes turn over
})
.superfish(); // call supersubs first, then superfish
});
</script>
</div><!--branding-->
<?php if ( $data['menu_separated'] == 1 ) { ?>
<div id="nav-holder" class="<?php echo $data['layout']; ?>">
<nav id="site-navigation" class="main-navigation" role="navigation">
<?php wp_nav_menu(array('theme_location' => 'main_navigation', 'container' => false,'menu_id'=>'menu-main-navigation','menu_class' => 'sf-menu sf-js-enabled sf-shadow', 'fallback_cb'=> 'terrifico_selectmenu', )); ?>
</nav><!--site-navigation-->
</div>
<?php } ?>
<?php if ( $data['front_page_blog_index'] == 1 ) {?>
<?php if (! is_home()) { ?>
<?php if ( $data['page_header_on'] == 1 ) { ?>
<?php get_template_part( 'page-header' ); ?>
<?php } ?>
<?php } ?>
<?php } else { ?>
<?php if ( $data['page_header_on'] == 1 ) { ?>
<?php get_template_part( 'page-header' ); ?>
<?php } ?>
<?php } ?>
The file you need to edit is top-panel.php, in the same directory as header.php. It contains the expanded PHP code for that part of the header in your theme. You can see where it's referenced in header.php here, just above where you currently have the language bar code:
<?php if ( $data['top_panel_enable'] == 1 ) { get_template_part( 'top-panel' ); }; ?>
It's increasingly common for WordPress themes, when their designers want to keep everything tidy, to have usual theme parts like header.php, footer.php, etc. divided even further into sub-files. In other words, top-panel.php is to header.php, like header.php is to index.php.
First, back up any files you edit, then carefully insert the language bar code in top-panel.php so the file looks something like this:
<?php
/**
* #package Terrifico
*/
global $data; ?>
<div id="top-panel" class="<?php echo $data['layout']; ?>">
<div id="info-box">
<?php if ( $data['top_contact_enable'] == 1 ) { get_template_part( 'contact-bar' ); }; ?>
<?php if(class_exists('Woocommerce')) { ?>
<?php if ( $data['header_social_enable'] == 1 && $data['shopping_cart_enable'] == 0 ) { get_template_part( 'social-bar' ); }; ?>
<?php if ( $data['shopping_cart_enable'] == 1 ) { get_template_part( 'shopping-cart' ); } ;?>
<?php } else { ?>
<?php if ( $data['header_social_enable'] == 1 ) { get_template_part( 'social-bar' ); }; ?>
<?php } ?>
/* INSERT LANGUAGE BAR CODE */
<?php if( function_exists( 'simple_language_switcher' ) ) { ?>
<div id="simple-language-switcher"><?php simple_language_switcher(); ?></div>
<?php } ?>
/* END LANGUAGE BAR CODE */
</div><!-- #info-box -->
</div><!-- #top-panel -->
Basically, you want the language bar code to be inside the top-panel <div>. That's the div that contains the other divs for "Have any questions?", social icons, etc.
I don't actually have the theme installed to experiment with right now, but you'll probably have to play a little with the CSS or the code above to get it positioned perfectly. Hope I explained it clearly enough and that this helps.
so I am building a custom wordpress theme for a client (I am a freelancer, pretty new to wordpress) and I have built the main theme that works 100% on the home page, but when I go into a post, archive, etc, the image path breaks, the sidebar breaks. I have attached photos for you to see:
And this is what the post looks like:
======== code edit =======
header.php:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>" />
<?php if (is_search()) { ?>
<meta name="robots" content="noindex, nofollow" />
<?php } ?>
<title>
<?php
if (function_exists('is_tag') && is_tag()) {
single_tag_title("Tag Archive for ""); echo '" - '; }
elseif (is_archive()) {
wp_title(''); echo ' Archive - '; }
elseif (is_search()) {
echo 'Search for "'.wp_specialchars($s).'" - '; }
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>
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="wp- content/themes/custom1/css/reset.css" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
<!-- HTML 5 shiv -->
<!--[if lt IE 9]>
<script src="dist/html5shiv.js"></script>
<![endif]-->
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">
<?php if ( is_singular() ) wp_enqueue_script('comment-reply'); ?>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page-wrap">
<section id="header">
<div id="logo"></div>
<div id="nav">
<div class="wrapper">
<nav>
<ul>
<!-- <li>Home</li>
<li>About Us</li>
<li>FAQ's</li>
<li>Contact Us</li> -->
<?php wp_nav_menu(array('menu' => 'Main Nav Menu')); ?>
</ul>
</nav>
<div class="clear"></div>
</div>
</div>
</section> <!-- end of Header -->
<section id="page">
<div class="wrapper">
index.php:
<?php get_header(); ?>
<section id="main_content">
<article>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?> </h2>
<?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
<div class="entry">
<?php the_content(); ?>
</div>
<div class="postmetadata">
<?php the_tags('Tags: ', ', ', '<br />'); ?>
Posted in <?php the_category(', ') ?> |
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
</div>
</div>
<?php endwhile; ?>
<?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
<?php else : ?>
<h2>Not Found</h2>
<?php endif; ?>
</article>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
and page.php (the buggy one):
<?php get_header(); ?>
<section id="main_content">
<article>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
<div class="entry">
<?php the_content(); ?>
<?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>
</div>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
<?php // comments_template(); ?>
<?php endwhile; endif; ?>
</article>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
sorry for the long post :)
So I found the answer after alot of searching in a random blog post (I forgot where, sorry).
What I was doing: the image only worked on the homepage and no other page if I put the link to the image as: wp-content/themes/[mytheme]/images/image.jpg
and it worked on all other pages but not the home page when I put the following: ../wp-content/themes/[mytheme]/images/image.jpg
<?php bloginfo('template_directory'); ?>/images/image1.jpg
So thank you to Nicholas King, George Marques, Domdev and Scott Simpson for putting me on the right track.
Thanks,
Josh
My wordpress*(a custom template)* nav is all working on all of the pages but now I found out that the Main nav doesn't show on this pages
All pages e.g. search.php, single.php, index.php, page.php all has <?php get_header(); ?>
I really don't know whats wrong.
Here is the code for my header.php
<?php
/**
* #package WordPress
* #subpackage Default_Theme
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes() ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen,projection" />
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/sifr.css" type="text/css" />
<script src="<?php bloginfo('template_url'); ?>/js/sifr.js" type="text/javascript"></script>
<script src="<?php bloginfo('template_url'); ?>/js/sifr-config.js" type="text/javascript"></script>
<script src="http://cdn.jquerytools.org/1.1.2/jquery.tools.min.js"></script>
<?php wp_head(); ?>
</head>
<?php
$current_page = $post->ID;
$parent = 1;
while($parent) {
$page_query = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
$parent = $current_page = $page_query->post_parent;
if(!$parent) $parent_name = $page_query->post_name;
}
?>
<body id="<?php echo (is_page()) ? "$parent_name" : ((is_home()) ? "blog" : ((is_search()) ? "other" : ((is_single()) ? "blog" : "blog"))); ?>">
<div id="BGtie">
<!--HEAD WRAPPER-->
<div id="headwrapper">
<!--HEADER-->
<div id="headContainer">
<div id="nameTag">
<?php bloginfo('name'); ?>
</div>
<!--TOP NAV-->
<div id="topNav">
<ul>
<li>Home</li>
<li>Request info</li>
<li>Contact us</li>
<?php do_action('icl_language_selector'); ?>
</ul>
</div>
<!--END TOP NAV-->
<!--MAIN NAV-->
<?php if ( is_page() AND (strtolower(ICL_LANGUAGE_CODE) == 'fr') ) {include("main-nav-fr.php");} ?>
<?php if (is_page() AND (strtolower(ICL_LANGUAGE_CODE) == 'en')) include("main-nav-en.php") ?>
<!--END MAIN NAV-->
</div>
<!--END HEADER-->
</div>
<!--END HEAD WRAPPER-->
</div>
<!--MAIN NAV-->
<?php if ( is_page() AND (strtolower(ICL_LANGUAGE_CODE) == 'fr') ) {include("main-nav-fr.php");} ?>
<?php if (is_page() AND (strtolower(ICL_LANGUAGE_CODE) == 'en')) include("main-nav-en.php") ?>
<!--END MAIN NAV-->
is_page() returns false when in blog post. Remove the is_page and you should be fine.
Further reading - http://codex.wordpress.org/Conditional_Tags