0

I created a page which is listed in the top navbar but if i click on the link it loads a new page without the content of the page itself. That is the page shown after clicking on the admin link in the menu:

enter image description here

the content from the backend should be: enter image description here

And the code from the index.php file:

<?php get_header(); ?>

    <div class="row">

        <div class="col-sm-8 blog-main">

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

                get_template_part( 'content', get_post_format() );

            endwhile; endif; 
            ?>

            </div><!-- /.blog-main -->

                <?php get_sidebar(); ?>

        </div><!-- /.row -->

<?php get_footer(); ?>

the code from the content.php:

<select name="page-dropdown"
 onchange='document.location.href=this.options[this.selectedIndex].value;'> 
 <option value="">
<?php echo esc_attr( __( 'Select page' ) ); ?></option> 
 <?php 
  $pages = get_pages(); 
  foreach ( $pages as $page ) {
    $option = '<option value="' . get_page_link( $page->ID ) . '">';
    $option .= $page->post_title;
    $option .= '</option>';
    echo $option;
  }
 ?>
</select>

the code from the page.php:

<?php get_header(); ?>

    <div class="row">
        <div class="col-sm-12">

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

                    get_template_part( 'content', get_post_format() );

                endwhile; endif; 
            ?>

        </div> <!-- /.col -->
    </div> <!-- /.row -->

<?php get_footer(); ?>

why is the content not be shown? and why is the select page dropdown 4times on the startpage and just one time on the admin-page?

I'm ussing following plugins: - Hide Admin Bar - Nav Menu Roles - Theme My Login - WP Mail SMTP

And if i disable all plugins it is still the same. After your comment i changed my page.php to:

get_header(); ?>

<div id="main-content" class="main-content">

<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
    // Include the featured content template.
    get_template_part( 'featured-content' );
}
?>
    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

            <?php
                // Start the Loop.
            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;
            ?>

        </div><!-- #content -->
    </div><!-- #primary -->
    <?php get_sidebar( 'content' ); ?>
</div><!-- #main-content -->

<?php
get_sidebar();
get_footer();

but still don't get any content if i click on the page link

  • first of all, a page with a post_format? Try the original one. Also, check if your template part has the echo. GL – marvinpoo May 7 '18 at 13:07
  • that line of code was actually from a tutorial from taniarascia.com/developing-a-wordpress-theme-from-scratch what do you mean by check if your template part has the echo? Thank you – J. Doe May 7 '18 at 13:11
  • as example, my page templates load template parts like get_template_part( 'content', 'page' );, yours looks like it is trying to load a post-template inside a page template. Is you content-***.php saying <?php the_content(); ?> somewhere? – marvinpoo May 7 '18 at 13:15
  • no it isn't so if I only have pages without any comments, can i just put your line of code into my content.php? I mean now it is showing the content but is this how you do it? – J. Doe May 7 '18 at 13:26
  • try using the page.php and call the content in there if you don't have multiple page templates. Edit: check the twentyeighteen theme for examples – marvinpoo May 7 '18 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.