I need to put the_excerpt (); in the Wordpress entries but I can not find the file

0

I am asked to find the file that contains this code.

<?php
get_header();
if (have_posts()) :
   while (have_posts()) :
  the_post();
  the_content();
 endwhile;
endif;
get_sidebar();
get_footer(); 
?>

In this code I have to add the_excerpt(); so that apart from leaving the title and the content there is something else. And this something else will enter the client. But I have never touched wordpress and I do not know what file I have to touch.

    
asked by Laura 29.03.2017 в 10:44
source

2 answers

0

Wordpress Excerpt excerpt are optional summaries or descriptions of an article; simply a summary of the article.

The Excerpts have two main uses:

  • Replace full content in RSS feeds when the option to show abstracts is selected in Desktop > Options > Reading.
  • Depending on the WordPress theme, it can be shown in places where quick summaries are preferable before the full content:

    • Search results
    • Tag files
    • Category Files
    • Monthly files
    • Author files
  • Present the Wordpress excerpts

    To present Wordpress extracts within the Loop (loop) just call the function the_excerpt() inside the while loop, in the same way you call the other functions, since the_excerpt() is a function like the others that you have there: the_post(); or the_content();

    For example:

    <?php
    get_header();
    if (have_posts()) :
       while (have_posts()) :
          the_post();
          the_content();
          the_excerpt();
       endwhile;
    endif;
    get_sidebar();
    get_footer(); 
    ?>
    

    For more information, you can consult Wordpress Codex

        
    answered by 29.03.2017 в 11:20
    0

    That function is invoked from the templates of the wordpress theme that you are using, and depending on the theme, it will be added in certain places and not in others.

    This means that:

    <?php
        get_header();
        if (have_posts()) :
           while (have_posts()) :
          the_post();
          the_content();
         endwhile;
        endif;
        get_sidebar();
        get_footer(); 
    ?>
    

    Just as you present it, may not be literal in any of the templates of your theme . The only thing you will find in them, whatever the theme, is the use of the_content(); . And that's what you want to modify. The wrapper you're trying to follow was probably for another theme.

    Within your theme, there are templates (for example single.php and page.php where it does not make sense to present the excerpt ), while in others, which today display the full post, what you you want is, in exchange, to display only one intro plus a link that says: "Read more".

    In summary : Within the theme you're using, you should find which templates use "the_content ();"

    As I said before, there are templates where it is not appropriate to change ( single.php and page.php if your theme has them), and others that do not print posts, as functions.php . Some candidates, within your theme, can be called:

    • index.php
    • category.php
    • tag.php
    • loop.php

    For no reason you're going to get into modifying wp-includes/post-template.php . What you want to do must be strictly in your theme.

    If you want more help, supplement your question by listing the files that are inside the folder of your current theme.

        
    answered by 29.03.2017 в 12:57