Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to create my first wp theme. So far it has been quite nice experience, but now i have a problem that i don't quite understand.

The Admin bar is showing only on some of my pages, on the others it shows only white (actually transparent). Ex: on the Home page it is transparent (like if there is the empty place for it), but if i click the link to the "About us" page then i get the admin bar on that page. Actually it is transparent in almost ALL pages, except for the About us.

What i have checked and tried:

i have the "show toolbar when viewing the site" selected.

in header.php i do have the wp_head();

in footer.php i have the wp_footer();

i tried forcing it to show by adding to the functions.php

add_filter( 'show_admin_bar', '__return_true' );

but it doesn't make difference.

tried also to comment out all css: no change (to the bar, of course!)

tried deleting the custom js scripts: also no change.

looked at the code but found no pieces missing (like '' or ; or >)

When i see the bar (on the About us page) and right click > Inspect Element, it all seems ok. But on the pages where there is just the empty space and i do the same i see that there are several things missing just before the :

  • the wpadminbar

  • several scripts

Any ideas? If you need any more information just let me know what you need.

Maybe i am missing something very simple, and hopefully someone will be able to help me. THANKS!

here is my index.php:

<?php
get_header(); ?>
<?php get_sidebar(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

    <?php if ( have_posts() ) : ?>

        <?php /* Start the Loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>

            <?php
                /* Include the Post-Format-specific template for the content.
                 * If you want to override this in a child theme, then include a file
                 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );
            ?>

        <?php endwhile; ?>

        <?php _S_paging_nav(); ?>

    <?php else : ?>

        <?php get_template_part( 'content', 'none' ); ?>

    <?php endif; ?>

    </main><!-- #main -->
</div><!-- #primary -->

 <?php get_footer(); ?>

and my page.php

<?php
get_header(); ?>
<?php get_sidebar(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

        <?php while ( have_posts() ) : the_post(); ?>

            <?php get_template_part( 'content', 'page' ); ?>

            <?php
                // If comments are open or we have at least one comment, load up the comment template
                if ( comments_open() || '0' != get_comments_number() ) :
                    comments_template();
                endif;
            ?>

        <?php endwhile; // end of the loop. ?>

    </main><!-- #main -->
</div><!-- #primary -->

 <?php get_footer(); ?>

and the footer.php

    </div><!-- #content -->

    <footer id="colophon" class="site-footer" role="contentinfo">
        <div class="site-info">
            <?php do_action( '_S_credits' ); ?>
            <a href="http://wordpress.org/" rel="generator"><?php printf( __( 'Proudly powered by %s', '_S' ), 'WordPress' ); ?></a>
            <span class="sep"> | </span>
            <?php printf( __( 'Theme: %1$s by %2$s.', '_S' ), 'SEEMPLE', '<a href="http://AuthorURIHere" rel="designer">LUISPATO</a>' ); ?>
        </div><!-- .site-info -->
    </footer><!-- #colophon -->
</div><!-- #page -->

<?php wp_footer(); ?>
</body>
</html>
share|improve this question
    
Do you actually use the footer.php on every page? Is it always the same file? –  toscho Jan 5 at 17:28
    
i think so. i have only one footer.php. and then, for instance in page.php i use <?php get_footer(); ?> –  Boguz Didgeridoo Jan 5 at 17:32
    
can you add both of your index.php and page.php template code ? –  Shazzad Jan 5 at 17:38
    
Look at the source of a page where the admin bar does not show up. Do you see a </html> at the end of the file? –  s_ha_dum Jan 5 at 17:57
    
when i go to "View source code" the last thing i see is: </footer><!-- .entry-meta --> </article><!-- #post-## --> So, no </body> or </html> –  Boguz Didgeridoo Jan 5 at 18:05

2 Answers 2

This Sounds like a HTML problem. If you did not close all the tags in the theme or have open html tags in the post content eg (Copied and pasted text containing html, into the editor) it can forces the browser to ignore tags and since the wp-admin-bar is rendered last on every page, this is probably it.

Try to Viwe sorce and look for the admin bar html, and then take a look the code visa the Element Inspector and see if the browser just ignored it.

In the footer.php do you call the wp_footer() function?

share|improve this answer
    
in the element inspector there is no admin bar at all. I have just posted the index.php and the page.php, maybe someone can spot the problem there! –  Boguz Didgeridoo Jan 5 at 17:45
    
You have no <?php get_footer(); ?> in that code –  Robin Westerlundh Jan 5 at 17:46
    
sorry, there were the four spaces missing to show it as code. i think it is showing now... –  Boguz Didgeridoo Jan 5 at 17:48
    
How about "View page source" This outputs the pre interpreted html, no admin there? Also post the footer.php code, u need to have wp_footer() funtion called at the end –  Robin Westerlundh Jan 5 at 17:51
    
it doesn't show at all in the "View page source". i have wp_footer(); on the footer.php. i will add the code to the question. –  Boguz Didgeridoo Jan 5 at 17:53

First of all i would like to thank you for trying to help me!!

i found out what was causing it: it was an error on the functions.php:

it was missing:

require get_template_directory() . '/inc/template-tags.php';

i have added it back to the functions.php and now everything seems to be working fine.

Thank you!

=)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.