I am currently using
<?php if ( is_home() ) :
get_header( 'home' );
endif;
?>
To call 'header-home.php' on the homepage only.
I also want to call 'header-fullwidth.php' on our full width posts.
This is one of our full width posts: http://www.sickchirpse.com/photos-vatnajokull-glacier/
This is a normal post (it has a sidebar): http://www.sickchirpse.com/how-survive-european-squat-house-berlin/
What can I add to achieve this?
if(get_page_template() == 'your-full-width-template'):
get_header( 'full-width' );
endif;
You can alwasy check the current page template path with the get_page_template() function.
Related
I would like to change to homepage of a wordpress website depending on the role of the user who is logged in.
For the simple case ( i.e. whether a user is logged in or not ) I have tried using the function is_user_logged_in()
the code is as below:
if(!is_user_logged_in()){
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
}else{
echo "you are logged in";
}
But the problem is that it changes the content in the each and every page. I would like to do that for a particular page only.. ( i.e. homepage ). How do i do that? Any help would be greatly appreciated.
To do it you would have to add another condition(s), e.g. for the homepage:
if(!is_user_logged_in() && is_home()){
...
}
And similarly for the other type of the content: is_page(), is_category(), is_author(), etc. Check out the docs here.
check for the Id of the page and compare it to your wanted specific page
also you could set a category for the pages you want to alter and check for that
I'm a bit new to this, but I researched this topic a bit online and can't seem to figure out what I'm doing wrong. So basically, I created a duplicate footer to call for the homepage. We use a marketing automation tool called Pardot and we don't want to track visits to the homepage. So I created a file in the footer folder next to "footer-default.php" called "footer-nopardot.php" that omits the code.
In the home.php file, I edit the bottom with
<?php
get_footer('nopardot'); ?>
But it appears the homepage is still calling the default footer. Any advice on what to do or what I'm doing wrong?
Thanks!
just add this to your home template:
<?php
if ( is_home() ) :
get_footer( 'nopardot' );
else :
get_footer();
endif;
?>
you can use this loop just replace the home or 404 by your page name where you want to display your footer:
<?php
if ( is_home() ) :
get_footer( 'home' );
elseif ( is_404() ) :
get_footer( '404' );
else :
get_footer();
endif;
?>
and since you are just changing your home page footer u can just do this
<?php
if ( is_home() ) :
get_footer( 'yourName' );
else :
get_footer();
endif;
?>
Make sure of the file name to be footer-yourName.php
and then call it as follow:
get_footer( 'yourName' );
hope that helps :)
Hi i am trying to use two different sidebars for both pages and posts.
For that I have used the following condition to test if it is a page (if yes call "sidebar-15" otherwise call "blog").
<?php
if (is_page()){
dynamic_sidebar( 'sidebar-15' );
}
else {
get_sidebar( 'blog' );
}
?>
But, on pages it is still calling blog side bar. Is there something that I am doing wrong?
get_sidebar function
<?php get_sidebar( $name_of_sidebar_file ); ?>
for example:
files: sidebar-right.php and sidebar-left.php
calling:
get_sidebar('right');
get_sidebar('left');
I have a div of services (full width) which I only want to display on the home page of my Wordpress site. I have used the conditional tag if(is_home()) and it is working fine. But when I added a new template this division is showing up in the template page, too. I tried using:
(if(is_home())&&(!is_page_template('blog.php'))
...but unfortunately it is not working. I have also tried it using ID and slug, and yet still this particular div is coming in the template.
I some how want this div to show up only on the homepage. You can see the services div here. The same is being displayed here, but not in other inner pages.
Use is_front_page() instead.
See Here
This code
<?php if (is_home()) : ?>
// yes, home page
<?php else : ?>
//no, not home page
<?php endif; ?>
Simply use
if(is_home() && !is_page_template('blog.php'))
Everything Should be in one condition
You can do it with any of the following conditional tags
if( is_home() && !is_page_template( 'page- template-Blog-php' ) ) {
// service div here
}
Note: If you are using template in any folder you need to give folder path too.
For example: If you are placing all the templates in 'templates' folder your code will be:
if( is_home() && !is_page_template( 'templates/page-template-Blog-php' ) ) {
// service div here
}
or you can try following code:
if( is_home() || is_front_page() ) {
// service div here
}
Braces wrongly placed:
if( (is_home()) && (!is_page_template('blog.php')) )
is there a wordpress function that I can use to detect pages? example of what I want to do is below.
<?php if( is_FUNCTION_page('Contact Us') ) : ?>
...display this <div> / xhtml
<?php else: ?>
something else <div>
<?php endif;?>
Check is_page() function:
is_page();
// When any single Page is being displayed.
is_page(42);
// When Page 42 (ID) is being displayed.
is_page('Contact');
// When the Page with a post_title of "Contact" is being displayed.
is_page('about-me');
// When the Page with a post_name (slug) of "about-me" is being displayed.
is_page(array(42,'about-me','Contact'));
// Returns true when the Pages displayed is either post ID 42, or post_name "about-me", or post_title "Contact". Note: the array ability was added at Version 2.5.
Yeah. Use Wordpress is_page function to do that.
Example:
<?php if( is_page('Contact Us') ) : ?>
<div> Your If content goes here </div>
<?php else: ?>
<div> something else </div>
<?php endif;?>
NOTE:
Cannot Be Used Inside The Loop
Due to certain global variables being overwritten during The Loop is_page() will not work. In order to use it after The Loop you must call wp_reset_query() after The Loop.