Add custom URL to WordPress Header - php

I need to add custom urls to header. I edited Header.php and added this code:
<?php
print "<a href=localhost/URL1>URL1</a>/<a href=localhost/URL2>URL2</a>";
?> but for some reason URL1 and URL2 are not working.... Can someone help me with this problem?
EDIT: Here is header.php code
<?php
// Exit if accessed directly
if ( !defined('ABSPATH')) exit;
/**
* Header Template
*
*
* #file header.php
* #package Responsive
* #author Emil Uzelac
* #copyright 2003 - 2013 ThemeID
* #license license.txt
* #version Release: 1.3
* #filesource wp-content/themes/responsive/header.php
* #link http://codex.wordpress.org/Theme_Development#Document_Head_.28header.php.29
* #since available since Release 1.0
*/
?>
<!doctype html>
<!--[if !IE]> <html class="no-js non-ie" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 9 ]> <html class="no-js ie9" <?php language_attributes(); ?>> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]-->
<head>
<meta charset="<?php bloginfo('charset'); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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 wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php responsive_container(); // before container hook ?>
<div id="container" class="hfeed">
<?php responsive_header(); // before header hook ?>
<div id="header">
<?php responsive_header_top(); // before header content hook ?>
<?php if (has_nav_menu('top-menu', 'responsive')) { ?>
<?php wp_nav_menu(array(
'container' => '',
'fallback_cb' => false,
'menu_class' => 'top-menu',
'theme_location' => 'top-menu')
);
?>
<?php } ?>
<?php responsive_in_header(); // header hook ?>
<?php if ( get_header_image() != '' ) : ?>
<div id="logo">
<img src="<?php header_image(); ?>" width="<?php if(function_exists('get_custom_header')) { echo get_custom_header() -> width;} else { echo HEADER_IMAGE_WIDTH;} ?>" height="<?php if(function_exists('get_custom_header')) { echo get_custom_header() -> height;} else { echo HEADER_IMAGE_HEIGHT;} ?>" alt="<?php bloginfo('name'); ?>" />
</div><!-- end of #logo -->
<?php endif; // header image was removed ?>
<?php if ( !get_header_image() ) : ?>
<div id="logo">
<span class="site-name"><?php bloginfo('name'); ?></span>
<?php echo "<a href='www.google.com'>URL1</a>/<a href='www.google.com'>URL2</a>"?>;
<span class="site-description"><?php bloginfo('description'); ?></span>
</div><!-- end of #logo -->
<?php endif; // header image was removed (again) ?>
<?php get_sidebar('top'); ?>
<?php wp_nav_menu(array(
'container' => 'div',
'container_class' => 'main-nav',
'fallback_cb' => 'responsive_fallback_menu',
'theme_location' => 'header-menu')
);
?>
<?php if (has_nav_menu('sub-header-menu', 'responsive')) { ?>
<?php wp_nav_menu(array(
'container' => '',
'menu_class' => 'sub-header-menu',
'theme_location' => 'sub-header-menu')
);
?>
<?php } ?>
<?php responsive_header_bottom(); // after header content hook ?>
</div><!-- end of #header -->
<?php responsive_header_end(); // after header container hook ?>
<?php responsive_wrapper(); // before wrapper container hook ?>
<div id="wrapper" class="clearfix">
<?php responsive_wrapper_top(); // before wrapper content hook ?>
<?php responsive_in_wrapper(); // wrapper hook ?>
Ok here is code od header.php. I added custom URLs but they are not displayed on website.

You have placed the anchor tag for URL1 and URL2 in
if ( !get_header_image() )
which means it would show both the URLs only when there is no header image and if this is correct try placing the code inside
<?php if ( get_header_image() != '' ) : ?>
and also you are using the wrong form of the url you are using
<a href='www.google.com'>URL1</a>
but rather try using complete url which is
<a href='http://www.google.com'>URL1</a>

whats not working? does clicking link give 404?
if 404, then, as suggested, change href to a valid uri.
anything added to header.php will show on frontend, so only your href uri can be the issue, as far as the info you have provided for us goes.
Good Luck :)

Related

Why does my WordPress site title have a "-" in front of it?

I'm trying to update my site title to say "Welcome to Etheric City". I did this just simply in the wordpress site identity tab and it worked but I have a random dash ("-") in front of it now like the image here -->
The code in the header.php file doesn't show any dashes so was wondering what I'm missing? I entered in the site title manually and didn't copy and paste from anywhere. Header.php code below:
<?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 Signify
*/
?>
<!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">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php do_action( 'wp_body_open' ); ?>
<div id="page" class="site">
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'signify-music-dark' ); ?></a>
<header id="masthead" class="site-header">
<div class="site-header-main">
<div class="wrapper">
<?php get_template_part( 'template-parts/header/site', 'branding' ); ?>
<?php get_template_part( 'template-parts/navigation/navigation', 'primary' ); ?>
</div><!-- .wrapper -->
</div><!-- .site-header-main -->
</header><!-- #masthead -->
<?php signify_sections(); ?>
<div id="content" class="site-content">
<div class="wrapper">
Any help is greatly appreciated!
Its display inside head or document section. You can remove using filter hook.
Reference : https://developer.wordpress.org/reference/hooks/document_title_separator/
/**
* Remove title whitespace.
*/
function modify_document_title_separator( $separator ) {
return "";
}
add_filter( 'document_title_separator', 'modify_document_title_separator', 10, 1 );

How do I change – (endash) to | (vertical bar) in my browser?

In the browser tab info of my site I want to replace the dash with a vertical line.
So instead of Site Name - Site Tagline it would be Site Name | Site Tagline. It would also be like that on category pages, for example right now it is Site Name - Site Category but I would like Site Name | Site Category. I am using the Goodlife theme but I have added the header.php below. Does anyone know how I could change this?
header.php
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_site_icon(); ?>
<?php
$header_style = ot_get_option('header_style', 'style1');
$general_boxed = (ot_get_option('general_boxed') == 'on' ? 'boxed' : '');
?>
<?php
/* 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="wrapper" class="open">
<!-- Start Mobile Menu -->
<?php do_action( 'thb_mobile_menu' ); ?>
<!-- End Mobile Menu -->
<!-- Start Content Container -->
<section id="content-container">
<!-- Start Content Click Capture -->
<div class="click-capture"></div>
<!-- End Content Click Capture -->
<?php
get_template_part( 'inc/header/fixed' );
get_template_part( 'inc/header/subheader' );
get_template_part( 'inc/header/'.$header_style );
get_template_part( 'inc/header/pageskin' );
?>
<div role="main" class="<?php echo esc_attr($general_boxed); ?>">
According to this article, you need to add the following code inside functions.php:
function wploop_change_separator()
{
return '|';
}
add_filter('document_title_separator', 'wploop_change_separator');

Translating webpage in WordPress with PHP

I am looking to translate my wordpress page based on adding a parameter ?lang=de_DE.
Below is my index.php file :
<!DOCTYPE HTML>
<html<?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<?php wp_head(); ?>
</head>
<body>
<h1> <?php echo __('This is our website','basictheme');?> </h1>
<?php wp_footer(); ?>
</body>
</html>
functions.php file
<?php
function basictheme_functions() {
load_theme_textdomain('basictheme',get_template_directory_uri().'/lang');
add_theme_support('title-tag');
register_nav_menus(array(
'main-menu' => __('Main Menu','basictheme'),
'footer-menu' => __('Footer Menu','basictheme'),
));
}
add_action('after_setup_theme','basictheme_functions');
?>
How can I translate the page when I add the parameter to the URL.
(e.g http://localhost/about/?lang=de_DE)

Wordpress:Display A specific Header for a Page

I have been trying To have No header for My Landing Page,but a sticky nav Bar On the header for the rest of my pages.
I edited the header(header.php),but it gets applied to all the pages.I would like The header To not show on the landing page.
Here is my code.
<?php
/*
* Header Section of Iconic One
*
* Displays all of the <head> section and everything up till <div id="main">
*
* #package WordPress - Themonic Framework
* #subpackage Iconic_One
* #since Iconic One 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">
<?php if ( get_theme_mod( 'themonic_logo' ) ) : ?>
<div class="themonic-logo">
<img src="<?php echo get_theme_mod( 'themonic_logo' ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
</div>
<?php if( get_theme_mod( 'iconic_one_social_activate' ) == '1') { ?>
<div class="socialmedia">
<img src="<?php echo get_template_directory_uri(); ?>/img/twitter.png" alt="Follow us on Twitter"/> <img src="<?php echo get_template_directory_uri(); ?>/img/facebook.png" alt="Follow us on Facebook"/> <img src="<?php echo get_template_directory_uri(); ?>/img/gplus.png" alt="Follow us on Google Plus"/><img src="<?php echo get_template_directory_uri(); ?>/img/rss.png" alt="Subscribe RSS"/>
</div>
<?php } ?>
<?php else : ?>
<hgroup>
<?php bloginfo( 'name' ); ?>
<br .../> <a class="site-description"><?php bloginfo( 'description' ); ?></a>
</hgroup>
<?php if( get_theme_mod( 'iconic_one_social_activate' ) == '1') { ?>
<div class="socialmedia">
<img src="<?php echo get_template_directory_uri(); ?>/img/twitter.png" alt="Follow us on Twitter"/> <img src="<?php echo get_template_directory_uri(); ?>/img/facebook.png" alt="Follow us on Facebook"/> <img src="<?php echo get_template_directory_uri(); ?>/img/gplus.png" alt="Follow us on Google Plus"/><img src="<?php echo get_template_directory_uri(); ?>/img/rss.png" alt="Follow us on rss"/>
</div>
<?php } ?>
<?php endif; ?>
<div class="clear"></div>
</header><!-- #masthead -->
<div id="main" class="wrapper">
I have removed The nav bar on this File,But i wish to use the nav bar on all my other pages.
I tried the IS page() function,but it Does not work,for me at least.Could someone provide an example on how this should be done
You need to create static "template page",
your first one would be your home page.
<?php /* Template Name: Homepage */?>
<?php get_header();?>
-- BODY HERE --
<?php get_footer();?>
Now you create how many pages you got like this, Home, About, Service, Profile, Contact.
Now you don't need a template for every single page but it wouldn't hurt I would recommend doing that.
Finally to get the different header for other page you just create a different header-other.php and use it instead of the header.php....
Make sure you use -name.php because you will call it like this on the page you want.
<?php get_header('name');?>
so anything past the - you put in here and WordPress will know that you are trying to use that HEADER.
I hope this helps and solves all your issues, best of luck with your project.

Realy need some help with social sharing button

I bump into this problem:
When you go to my website: http://www.appartementtekooputrecht.nl and click on the twitter share button, it directs twitter to http://www.appartementtekooputrecht.nl/samenvatting (last page) in stead of to the homepage.
I have placed the share plugin share code in more parts of the theme, but with no good result.
Fyi in this theme all pages are displayed on the homepage.
Any help would be realy appreciated!
here is my header.php (share is at the end)
<?php global $shortname; ?>
<!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 profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php elegant_titles(); ?></title>
<?php elegant_description(); ?>
<?php elegant_keywords(); ?>
<?php elegant_canonical(); ?>
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/style.css" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/ie6style.css" />
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/DD_belatedPNG_0.0.8a-min.js"></script>
<script type="text/javascript">DD_belatedPNG.fix('img.overlay, div#content-bg-bottom');</script>
<![endif]-->
<?php wp_head(); ?>
</head>
<body>
<div id="wrapper">
<div id="content">
<div id="content-bg-bottom">
<div id="header">
<ul>
<li class="active">Home</li>
<?php query_posts(array
('post_type' => 'page',
'orderby' => get_option('myresume_nav_sort_pages'),
'order' => get_option('myresume_nav_order_page'),
'post__not_in' => get_option('myresume_nav_exclude_pages')
)); ?>
<?php if (have_posts()) : while (have_posts()) : the_post()?>
<li><?php the_title() ?></li>
<?php endwhile; endif; wp_reset_query(); ?>
</ul>
<br class="clear" />
<div id="logo">
<img class="avatar" alt="Appartement te koop Utrecht Utrecht" src="http://www.tim-productions.tv/appartementtekooputrecht.nl/wp-content/themes/MyResume/images/appartement-te-koop-utrecht-logo.jpg" />
<img class="overlay" src="<?php bloginfo('template_directory'); ?>/images/photo-overlay.png" alt="" />
<span>
<br />
<?php echo(get_option('myresume_email')) ?>
<br />
<?php echo(get_option('myresume_phone')) ?>
</span>
</div>
</div>
<div id="inside">
<div id="inside-bg-top">
<div id="inside-bg-bottom">
<div class="resume slide">
<div class="social"><?php lacands_wp_filter_content_widget(); ?></div>
And here the theme index.php
<?php get_header(); ?>
<?php query_posts(array
('post_type' => 'page',
'orderby' => get_option('myresume_sort_pages'),
'order' => get_option('myresume_order_page'),
'post__in' => get_option('myresume_exclude_pages')
)); ?>
<?php if (have_posts()) : while (have_posts()) : the_post()?>
<div class="page-content">
<div class="entry">
<?php the_content('') ?>
</div>
<h2><?php the_title() ?></h2>
</div>
<?php endwhile; endif; wp_reset_query(); ?>
<?php get_footer(); ?>
I downloaded that plugin and I can see in the code of the file "la-click-and-shared.php", around line 560, that the widget gets the links that passes to the social buttons from the permalink of the current post/page. What I can't know is why you have that permalink.
I would guess it must be a problem either with the permalink/name of the post, with the permalinks setting in general or with the AJAX functionality, but it is difficult to help you further without further details.
You could try these:
Check the permalink of that page or post you are showing as home.
Disable custom permalinks temporarily and see if it works then.
Is the Settings > Reading > Front page displays option set correctly?
Disable other plugins temporarily
Edit:
You could also edit la-click-and-shared.php. In the latest version that I just have downloaded, this is line 556:
$args['link'] = htmlentities($link1);
If you can't fix it any other way and/or you are in a hurry, you could just do:
$args['link'] = 'http://www.appartementtekooputrecht.nl';
Since your site only exposes that URL anyway it is not a big deal. But, of course, you are 'breaking' the plugin if you change your site in the future so it doesn't use AJAX (inappropriately in my opinion) to load all the pages with the same URL (no browsing history either).

Categories