Changing default language in WordPress on individual pages - php

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')
?>

Related

viewport is ignored when using php $this->beginBody() and endBody()

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">

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)

Head content appears in the body tag (Wordpress)

My head content(metas, scripts etc.) appears in the body tag. I have header php with this code
<!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>
<header class="header">
<h1 id="logo">|||</h1>
<h4 id='title' ><?php the_title(); ?></h4>
</header>
<body>
and footer.php is closing it with this. `
<?php wp_footer(); ?>
</body>
</html>`
Already tried changing encoding from UTF-8 to UTF-8 without BOM using Notepad++, and still the same ,, this is my website if you wanna see with inspect [website]
website . Any ideas ? :S
Your html is broken:
<title> Name Lastname / Official Website</title>
^---- missing >

how I can use header.php and footer.php outside from wordpress theme directory

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');
?>

Views in CakePhp INTERNAL SERVER ERROR

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' )

Categories