How to hide the navigation menu in a single wordpress page? - css

I have a site powered by wordpress. I need to hide the navigation menu in two specific pages but I couldn´t do it.
This is the page:
The menu is appearing like this:
In the bottom left side of the page. It´s need to be hide or remove.
Above, is the html of the menu
I tried this use this code:
.mob-menu-header-holder .mobmenu .mobmenur-container .mob-menu-left-panel .mobmenu_content .leftmtop .mob-menu-right-panel{display: none;}
Any ideas?

please try add this code in your functions.php
add_action('wp_head', 'add_css_head');
function add_css_head() {
if ( is_page( 'your-page-slug' ) || is_page( 'your-page-slug' ) ) {
?>
<style>
.your-css-class {
display:none
}
</style>
<?php
}
}
if one of page you want to hide is frontpage you can use this
add_action('wp_head', 'add_css_head');
function add_css_head() {
if ( is_front_page() || is_page( 'your-page-slug' ) ) {
?>
<style>
.your-css-class {
display:none
}
</style>
<?php
}
}

First of all you have to access your wordpress files. Then find custom .css or .less file if it's exist. And then add this code line in this file. But this line affect to whole site pages. So, if you want to affect only two pages, you have to add some codes to in your theme's index.php (I guess) file.
.mobmenu{ display:none!important; }

Related

Add custom wordpress templete to grandchild pages

I am currently working on a Wordpress theme and need to set custom templates to child and grandchild pages automatically, so a client wouldn't need to worry about selecting which template to choose.
The code I have already is:
<?php
if( $post->post_parent !== 0 ) {
get_template_part('child');
} else {
get_template_part('parent');
}
?>
The code is placed within page.php. This works great for child pages but I need to include something like 'if grandchild apply grandchild.php'.
Any help or advice will be much appreciated. Thanks =D
Try this...
if( count(get_post_ancestors($post->ID)) >= 2 ) {
enter code here
}
Making use of http://codex.wordpress.org/Function_Reference/get_post_ancestors

How do I exclude some code on posts and pages in wordpress?

I have a feature box on my header.php file, because of this the feature box gets displayed in every page and post page as well. What code do I need to keep this feature box only in the homepage and no place else?
You're looking for the is_front_page() function:
if ( is_front_page() ) {
// Show the feature box
} else {
// Do something else
}

How do I change the title of a Wordpress page within the template?

I am setting up a wordpress theme and it has the "logo" h1 tag at the top which shows the title of the site. On the blog page specifically though I'd like to change the title in the H1 tag.
I am aware there may be some php that does something like this: if blog page show this h1 tag (code) and for every other page show this h1 tag (code).
Is this possible?
Thanks kindly
Please use the below code instead of code which is now using to display the page title.
<?php
if ( is_page( '{enter your blog page slug here}' ) ) {
echo '<h1>{enter your blog page title here}</h1>';
} else {
echo '<h1>{enter your non-blog page title here}</h1>';
}
?>
You can query your current page template with meta.
You can get current page template this meta tag:
_wp_page_template
And full code:
if( get_post_meta($post->ID, '_wp_page_template', true) == "your-template.php" ){
// current page is created with your template
} else{
// other page template or defult template
}
Assuming you have separate template for your blog page, like blog.php in your theme directory.
Then you should follow below code:
if ( is_page_template( 'blog.php' ) ) {
// Current Template is Blog
} else {
// Other Pages
}
More info: http://codex.wordpress.org/Function_Reference/is_page_template
Update:
If blog the one of your page in WordPress then follow below code:
if(is_page('id or slug of WP Blog Page')) {
// This is blog page
} else {
// This is other page
}
If that does not work then you should try including different header files using get_header function.
More Info: http://codex.wordpress.org/Function_Reference/get_header
Suggestion: I would suggest to create new page template for your blog page and then you are good to go. You can refer this to create new page template and assign to page.

Wordpress shortcode - weird position on page

I created shortcode in my child themes functions.php file.
The shortcode is as follows:
function add_login_form() {
if ( is_user_logged_in() )
{
echo 'Witaj zalogowany';
}
else
{
wp_login_form();
}
}
add_shortcode('login_form', 'add_login_form');
I added shortcode [login_form] to my website (test area):
http://s540141209.domenaklienta.pl/wordpress/konto-klienta/
It is added to website after the text:
"TUTAJ POWINIEN BYĆ LOGIN FORM LUB NAPIS „WITAJ ZALOGOWANY”!"
It should be inside first div: <div class="et_pb_row">
But it is shown just after the header of a page. Have you any idea why it happens that way?
Thansk in advance.
But it happens to show before everything on website.
See http://codex.wordpress.org/Shortcode_API on how shortcodes acts. In a shortcode function you should always return the result of the processing done in the shortcode action. Echoing it outputs it as soon as the hook is executed, instead of being inserted in where it should be.
function add_login_form() {
if ( is_user_logged_in() )
{
return 'Witaj zalogowany';
}
else
{
return wp_login_form(array('echo'=>false));
}
}
add_shortcode('login_form', 'add_login_form');
For all arguments of wp_login_form, see http://codex.wordpress.org/Function_Reference/wp_login_form .

Making a page in wordpress that doesn't affect the other pages

The problem is that all the pages have a content_container of a set width of 1056px and I want all pages to have the 1056px set width except for the home page in which I need a content container that spans over the whole page from left to right.
Look at the CSS class on the BODY tag that WP uses on either page. Write your own CSS targeting the page you want.
add a class to the body of all the files (index.php and page.php) like this:
<body <?php body_class(); ?>>
and then target the home page with css:
body.home #content_container{width:100%; !important}
#content_container{width:1056px;}
You can do it like this also:
<?php
if ( is_home() ) {
//This is Home page
echo '<div id="content_container_wide">';
}
else {
// This is not a homepage
echo '<div id="content_container">';
}
?>

Resources