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)
Related
I am trying to make my website mobile friendly and it works when using inside head
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<?php $this->head(); ?>
</head>
<body>
<?php $this->beginBody() ?>
<?php echo $this->render('//layouts/_top_js'); ?>
<?= Alert::flashes() ?>
<?php echo $this->render('//layouts/_header'); ?>
<?= $content ?>
<?php echo $this->render('//layouts/_footer'); ?>
<?php echo $this->render('//layouts/_bottom_js'); ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
But when I start using the following code:
php $this->beginBody()
php $this->endBody()
it is completely ignored. Is the viewport code disabled when using the php code to load my pages?
The viewport needs to be explicitly set in the <head> section of your HTML. You should start the page with beginPage() instead of beginBody(), as the second one only renders the <body></body> part of the HTML.
PHP only outputs HTML on the page, in the case of Yii using layouts.
You need to check your layout files to make sure they contain the following line:
<meta name="viewport" content="width=device-width,initial-scale=1">
I am looking to translate pages in wordpress if the url contains the language /fr/ in the url. I am testing on a local site where I would like the language to default to french when I create the page http://localhost/fr/.
I would like to do this for multiple languages - for example
`http://localhost/de/`.
`http://localhost/es/`.
index.php
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<?php echo language_attributes();?>
<head>
<meta charset="<?php bloginfo('charset');?>">
<title>Page Title</title>
<?php wp_head(); ?>
</head>
<body>
<h1><?php echo __('This is a Heading','basictheme')?></h1>
<p>This is a new paragraph.</p>
<?php wp_footer(); ?>
</body>
</html>
functions.php
<?php
function basictheme_functions(){
load_theme_textdomain('basictheme',get_template_directory().'/lang');
}
add_action('after_setup_theme','basictheme_functions')
?>
I have a theme installed in wordpress like this directory /wp-content/themes/mytheme so in the root I have custom code which is little complex and easy to integrate in wordpress theme so I want to finding an option where I can use header.php and footer.php in root directory like this way. /custom_code/custom.php
After a lot of searching here is the solution.
<?php require('../wp-blog-header.php'); ?>
<?php get_header(); ?>
<!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">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo
('charset'); ?>" />
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php
wp_title(); ?></title>
<?php wp_head(); ?>
</head>
<body>
It works!
</body>
</html>
<?php get_footer(); ?>
Include header.php and footer.php like this:
http://codex.wordpress.org/Integrating_Wordpress_with_Your_Website
From the page:
<?php
/* Short and sweet */
define('WP_USE_THEMES', false);
require('./wp-blog-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 :)
I have the following Layout (called: "MyView.ctp") in /app/view/layouts
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $title_for_layout; ?></title>
<!-- add favicon here-->
<!-- js -->
<?php echo $scripts_for_layout; ?>
</head>
<body>
</body>
</html>
I have the following View (called MyView.ctp) in /app/view
<?php $html->css('fup-prototype','stylesheet', array('media”=>”all' ), false); ?>
The following css file (called fup-prototype.css) in app/webroot/css/
But am getting this error:
What am I doing wrong here?
Instead of
array('media”=>”all' )
you most likely meant
array('media'=>'all' )