How can I conditionally show different home page templates based on whether or not the user is logged in?

First check that there isn’t a page set as a front page in “Reading Setting”. If that is set, index.php is not used as the home page, but the template of the page you set as front page. In that case, you need to find that template and add you conditional is there. <?php if(is_user_logged_in()) … Read more

I restricted wordpress by logged users. It’s possible exclude a page?

I wanted to restrict my website except a specific page. This is my solution: function restrict_access_if_logged_out(){ global $wp; if (!is_user_logged_in() && !is_home() && ($wp->query_vars[‘pagename’] != ‘name-of-page’) ){ $redirect = home_url() . ‘/wp-login.php?redirect_to=’ . esc_url($_SERVER[“HTTP_HOST”] . urlencode($_SERVER[“REQUEST_URI”])); wp_redirect( $redirect ); exit; } } Only I added this: && ($wp->query_vars[‘pagename’] != ‘name-of-page’) in IF clause and a … Read more

My custom template page not loading content inside it?

you have to use the WP Loop to get page content. Try this <?php /* Template Name: home */ get_header(); ?> <div id=”theme-main-banner” class=”banner-three gradient-banner-three”> <?php while(have_posts()): the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> </div> <?php get_footer(); ?> UPDATE The issue was that front-page.php was already present in the theme. So as per the … Read more

Try to run a function only on Home

You’re calling it on the wrong hook, and you’re calling the wrong conditional function to test. When the after_setup_theme hook is fired, WordPress hasn’t finished processing wether you’re on a page or a homepage yet. You should also never pass in hardcoded post IDs. In this case is_home works, as might is_front_page. If you really … Read more

How can I confirm I’m on the home page

If you are using the default home page, which in most cases is a list of most recent posts, is_home() should work. If you have set a static page to be your front page (in Settings >> Reading), is_front_page() should work. If you are not getting the results you expect using this: if (is_front_page()) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)