Viewed   146 times

As it says in the title, I'm looking for multiple excerpt lengths in WordPress.

I understand you can do this in functions.php:

function twentyten_excerpt_length( $length ) {
    return 15;
}
add_filter( 'excerpt_length', 'twentyten_excerpt_length' );

What I want to know is how you can have multiple of these each returning different numerical values so I can get short excerpts for sidebar loops, longer excerpts for featured loops, and the longest excerpt for the main article.

Something like using these in the templates:

<?php the_excerpt('length-short') ?>
<?php the_excerpt('length-medium') ?>
<?php the_excerpt('length-long') ?>

Cheers, Dave

 Answers

3

How about...

function excerpt($limit) {
      $excerpt = explode(' ', get_the_excerpt(), $limit);

      if (count($excerpt) >= $limit) {
          array_pop($excerpt);
          $excerpt = implode(" ", $excerpt) . '...';
      } else {
          $excerpt = implode(" ", $excerpt);
      }

      $excerpt = preg_replace('`[[^]]*]`', '', $excerpt);

      return $excerpt;
}

function content($limit) {
    $content = explode(' ', get_the_content(), $limit);

    if (count($content) >= $limit) {
        array_pop($content);
        $content = implode(" ", $content) . '...';
    } else {
        $content = implode(" ", $content);
    }

    $content = preg_replace('/[.+]/','', $content);
    $content = apply_filters('the_content', $content); 
    $content = str_replace(']]>', ']]&gt;', $content);

    return $content;
}

then in your template code you just use..

<?php echo excerpt(25); ?>

from: http://bavotasan.com/tutorials/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/

Tuesday, September 6, 2022
2

try this way Html code

<p class="full_form"><label for="prop_category">We are into</label>
            <input type="checkbox" id="architecture" size="80" name="service_name[]"  value="Architecture" >Architecture
            <input type="checkbox" id="builder_developer" size="80" name="service_name[]"  value="Builders and Developeres">Builders and Developeres
            <input type="checkbox" id="material_supplier" size="80" name="service_name[]" value="Material Supplier">Material Supplier
            <input type="checkbox" id="contractor" size="80" name="service_name[]" value="Contractor">Contractor
            <input type="checkbox" id="int_decorator" size="80" name="service_name[]" value="Interior Decorator">Interior Decorator
            <input type="checkbox" id="prop_finance" size="80" name="service_name[]" value="Property Finance">Property Finance
            <input type="checkbox" id="prop_legal_ad" size="80" name="service_name[]"  value="Property Legal Advisor">Property Legal Advisor
            <input type="checkbox" id="prop_valuer" size="80" name="service_name[]"  value="Property Valuer">Property Valuer
            <input type="checkbox" id="vastu_consult" size="80" name="service_name[]" value="Vaastu Consultant">Vaastu Consultant

Submit code for save

<?php 
        //submit code 
          if(isset($_POST['service_name'])  ){
              $data=serialize($_POST['service_name']);

              update_post_meta($postid, 'service_name', $data);
          }
        ?>

Edit code

<?php 
        //edit code

            $data=get_post_meta($postid, 'service_name');
            //$data=unserialize($data[0]);
            $data=$data[0];
            print_r($data);

        ?> 

        <input type="checkbox" id="architecture" size="80" name="service_name[]"  value="Architecture" <?php if(in_array('Architecture',$data)  ){echo "checked";} ?> >Architecture



//other checkbox put as this 

in_array check it

Friday, August 5, 2022
3

You can "remove" the parent theme function with remove_action(). This function removes a function which has been attached to a specified action hook, and is often used to replace functions with a substitute:

remove_action('wp_head', 'aaron_customize_css');

And then add your own function in place of it:

add_action('wp_head', 'aaron_customize_css_child');

So, in all, you'll have something like the following in your child theme:

function aaron_customize_css_child() {
    remove_action('wp_head', 'aaron_customize_css');
    // function contents
}
add_action('wp_head', 'aaron_customize_css_child', 100);
Friday, December 16, 2022
 
rog
 
rog
2

I would guess you need to decode the search term you are extracting from the query string, like so: $search_query[$query_split[0]] = urldecode($query_split[1]). Although, you could probably just use Wordpress's get_query_var function instead of all that code.

Tuesday, October 11, 2022
 
4

I asked the same question over at Wordpress Answers - https://wordpress.stackexchange.com/questions/20915/wordpress-plugin-admin-page-using-wordpress-function-in-linked-php-file

I thought it best to simply link to the answer that helped me =) Thanks all.

Thursday, August 25, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :