2017-03-06 1 views
1

Ich versuche, einen Blick auf meine Wordpress-Theme zu machen und erhielt ich diesen Fehler:nicht erfasste Fehler: Aufruf der undefinierten Funktion have_post()

Fatal error: Uncaught Error: Call to undefined function have_post() in C:\xampp\htdocs\wordpress\wp-content\themes\ChachoTheme\index.php:6 Stack trace: #0 C:\xampp\htdocs\wordpress\wp-includes\template-loader.php(74): include() #1 C:\xampp\htdocs\wordpress\wp-blog-header.php(19): require_once('C:\xampp\htdocs...') #2 C:\xampp\htdocs\wordpress\index.php(17): require('C:\xampp\htdocs...') #3 {main} thrown in C:\xampp\htdocs\wordpress\wp-content\themes\ChachoTheme\index.php on line 6

index.php:

<?php if (have_post()):?> 
    <?php while(have_post()):the_post(); ?> 

<div id="post"> 

    <h2><a href="<?php the_permalink(); ?>"></a><?php the_title(); ?></h2> 
    <div class="byline">Escrito por <?php the_autor_posts_link(); ?> 
    el <a href="<?php the_permalink(); ?>"><?php the_time('l F d, Y'); ?></a> 
    </div> 
    <?php the_content('Read More..'); ?> 
<?php endwhile; ?> 
<?php else: ?> 
    <p>No posts were found. Sorry!")</p> 
<?php endif; ?> 

Wie kann Ich befestige es?

+0

Das Problem ist in index.php selbst nicht, sondern ein Der Aufruf von 'the_content' ruft intern eine Funktion' have_post() 'auf, die nicht existiert. (oder möglicherweise nicht in den Kontext einbezogen worden.) –

Antwort

1

Schreiben Sie Ihren Code wie folgt:

<?php 
    if (have_posts()) { 
     while (have_posts()) { 
?> 
      <div id="post"> 
       <h2><a href="<?php the_permalink(); ?>"></a><?php the_title(); ?></h2> 
       <div class="byline">Escrito por <?php the_autor_posts_link(); ?> el <a href="<?php the_permalink(); ?>"><?php the_time('l F d, Y'); ?></a></div> 
       <?php the_content('Read More..'); ?> 
      </div> 
<?php 
     } 
    } else { ?> 
     <p>No posts were found. Sorry!")</p> 
<?php } 
?> 
+0

Danke, yor Hilfe wird sehr geschätzt. – Jesusmbm17

3

versuchen have_posts() statt Ihre have_post()

auch the_autor_posts_link()-the_author_posts_link()

ändern
<?php if (have_posts()):?> 
    <?php while(have_posts()):the_post(); ?> 

<div id="post"> 

    <h2><a href="<?php the_permalink(); ?>"></a><?php the_title(); ?></h2> 
    <div class="byline">Escrito por <?php the_author_posts_link(); ?> 
    el <a href="<?php the_permalink(); ?>"><?php the_time('l F d, Y'); ?></a> 
    </div> 
    <?php the_content('Read More..'); ?> 
<?php endwhile; ?> 
<?php else: ?> 
    <p>No posts were found. Sorry!")</p> 
<?php endif; ?> 
+0

Danke für Sie Hilfe, seine Arbeit – Jesusmbm17

Verwandte Themen