1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

use Excerpt just in categories of wordpress theme

Discussion in 'Web Design' started by javadth, Sep 21, 2016.

  1. javadth

    javadth Junior Member

    Joined:
    Aug 27, 2012
    Messages:
    150
    Likes Received:
    10
    Gender:
    Male
    Home Page:
    hi in my theme i set full content for index , but i want to use Excerpt in categories for example show 300 word


    this is my index

    PHP:
    <?php get_header(); ?>
     


    <div id="content">

        <div id="main" role="main">
            <?php get_template_part('loop'); ?>
        </div>
       
        <?php get_sidebar(); ?>
       
    </div>
    <div class="clear"></div>

    <?php get_footer(); ?> 

    and this sis my loop php file

    PHP:
    <?php
     
        
    while (have_posts()) : the_post();  ?>
     
        <div id="post-<?php the_ID(); ?>" class="post clearfix">
            <div class="post-content">

                <h2 class="title"><a href="<?php the_permalink(); ?>" title="<?php printfesc_attr__'Permalink to %s''wpzoom' ), the_title_attribute'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
               
                <div class="top-meta">
                     <?php if (option::get('display_date') == 'on') { ?><span class="date"><?php printf__('%s at %s''wpzoom'),  get_the_date(), get_the_time()); ?></span><?php ?>
                     <?php edit_post_link__('Edit''wpzoom'), '<span>''</span>'); ?>
                  </div><div class="clear"></div>
               
                <div class="entry">
                    <?php if (option::get('display_content') == 'Full Content') {  the_content(''); } else { the_excerpt(); } ?>
                     
                       <div class="clear"></div>
                </div><!-- /.entry -->
            </div><!-- /.post-content -->
            <div class="clear"></div>

            <div class="post-meta clearfix">  
           
                <?php if (option::get('display_share') == 'on') { ?>
                   
                <?php ?>
               
                <?php if (option::get('display_readmore') == 'on') { ?><span class="readmore"><a href="<?php the_permalink() ?>"><?php _e('بیشتر بخوانید''wpzoom'); ?></a></span><?php ?>          

                <?php if (option::get('display_comments') == 'on') { ?><?php comments_popup_link'0''1''%''comments'__('Comments Off''wpzoom')); ?><?php ?>
                 
              </div>
           
        </div><!-- #post-<?php the_ID(); ?> -->
       
     
    <?php endwhile; ?>
    <?php get_template_part
    'pagination'); ?>
    <?php wp_reset_query
    (); ?>
     
  2. Emma Clark

    Emma Clark Newbie

    Joined:
    Aug 3, 2016
    Messages:
    21
    Likes Received:
    3
    Location:
    California
    Home Page:
    Great! WordPress development or customization are two important aspects for making your website more alluring in front of your customers. WordPress is highly customizable and allows to create a custom website or choose from many themes that can give your website the look and feel you want it to have. An impressive https://www.thinsquare.com/wordpress-development-services offers a successful website that means many visitors keep coming back to the site.
     
  3. RotatingProxies

    RotatingProxies Junior Member

    Joined:
    Oct 19, 2016
    Messages:
    116
    Likes Received:
    18
    Home Page:
    You can trim category titles using this in your loop / functions.php:

    Code:
    function trim_title() {
    $title = get_the_title();
    $limit = "200";
    $pad="...";
    
    if(strlen($title) <= $limit) {
    echo $title;
    } else {
    $title = substr($title, 0, $limit) . $pad;
    echo $title;
    }
    }