Skip to main content

How to Change the Excerpt Length? in wordpress

The two most common ways to change the excerpt length are either by doing it manually or by using a WordPress plugin.

Manually Changing WordPress Excerpt Length

The manual method involves tweaking the code. However, you don’t need to have in-depth knowledge in any programming language to do this.

Here are the steps to manually change the length of an excerpt:

  1. Hover on the Appearance tab and select Theme Editor.
  2. Open the functions.php file and insert the code:
    function mytheme_custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'mytheme_custom_excerpt_length', 999 );



  3. Change the word limit from 80 to any number you like, and press the Update File button.

For some themes, like Twenty Sixteen WordPress, you’ll need to edit the content.php file as well. Follow the guide below:

  1. While still in the Theme Editor, scroll down until you find template-parts. Under that heading, click on the content.php file.
  2. Search for the lines:
    <div class=“entry-content”>
    <?php

    Add the following code snippet just below them:

    if ( is_home() || is_category()||is_archive()){
    the_excerpt(‘‘);
    }else{
  3. Find the statements:
    ?>
    </div><!-- .entry content -->

    Then insert the following line above them:

    } // end of if statements
  4. Click Update File, and you’re done!

Comments

Popular posts from this blog

High light Search Result In Wordpress

High light Search Result In Wordpress add this function in your themes function.php function highlight_results ( $ text ) {      if ( is_search ( ) ) { $ keys = implode ( '|' , explode ( ' ' , get_search_query ( ) ) ) ; $ text = preg_replace ( '/(' . $ keys . ')/iu' , '<span class="search-highlight">\0</span>' , $ text ) ;      }      return $ text ; } add_filter ( 'the_content' , 'highlight_results' ) ; add_filter ( 'the_excerpt' , 'highlight_results' ) ; add_filter ( 'the_title' , 'highlight_results' ) ;   function highlight_results_css ( ) { ? > <style> .search-highlight { background-color : #FF0 ; font-weight : bold ; } </style> < ? php } add_action ( 'wp_head' , 'highlight_results_css' ) ;

Redirect In contact form 7

add_action( 'wp_footer' , 'redirect_cf7' ); function redirect_cf7() { ?> < script type = "text/javascript" > document.addEventListener( 'wpcf7mailsent' , function ( event ) { if ( '1377' == event.detail.contactFormId ) { // Sends sumissions on form 947 to the first thank you page location = 'https://www.panelesyceldassolares.com/regreso' ; } else { // Sends submissions on all unaccounted for forms to the third thank you page location = 'https://www.panelesyceldassolares.com/regreso-2/' ; } }, false ); </ script > <?php }

Get Single Product By ID in Opencart

<?php if(!empty($_POST["country_id"])) {     $query ="SELECT * FROM oc_product WHERE product_id = '" . $_POST["country_id"] . "'";     $results = $this->db->query($query);   $query2 ="SELECT * FROM oc_product_description WHERE product_id = '" . $_POST["country_id"] . "'";   $results2 = $this->db->query($query2);   $rowresults2 = $results2->row;   $rowresults = $results->row;   $name1 = $rowresults['model'];   $name2 = $rowresults2['name'];   $name3 = $rowresults['price'];   $name4 = 'Exe.' ?>