Plugin Directory

Changeset 1843147


Ignore:
Timestamp:
03/19/2018 10:47:23 PM (8 years ago)
Author:
raajtram
Message:

Add support for Search archives

Location:
multiple-excerpt-lengths/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • multiple-excerpt-lengths/trunk/multiple-excerpt-lengths.php

    r1337677 r1843147  
    33/*
    44Plugin Name: Multiple Excerpt Lengths
    5 Plugin URI: https://raajtram.com/plugins/mel
     5Plugin URI: https://raajtram.com/plugins/mel/
    66Description: Allows you to change the lengths of excerpts that are present at variours pages/templates throughout your site.
    7 Version: 1.0
     7Version: 1.1
    88Author: Raaj Trambadia
    99Author URI: https://raajtram.com/
     
    6363
    6464    add_settings_field(
     65        'mel_search',
     66        'Search Pages',
     67        'mel_search_cb',
     68        'multiple-excerpt-lengths',
     69        'mel_section'
     70    );
     71
     72    add_settings_field(
    6573        'mel_tax',
    6674        'Custom Taxinomy Archives',
     
    106114    if( !isset( $options['on_author'] ) ) $options['on_author'] = '';
    107115    echo '<input type="number" name="mel_settings[on_author]" value="' . $options['on_author'] . '" placeholder="55" min="1" max="999">';
     116}
     117
     118function mel_search_cb() {
     119    $options = get_option( 'mel_settings' );
     120    if( !isset( $options['on_search'] ) ) $options['on_search'] = '';
     121    echo '<input type="number" name="mel_settings[on_search]" value="' . $options['on_search'] . '" placeholder="55" min="1" max="999">';
    108122}
    109123
     
    158172    $is_tag = !empty( $options['on_tag'] ) ? $options['on_tag'] : '55';
    159173    $is_author = !empty( $options['on_author'] ) ? $options['on_author'] : '55';
     174    $is_search = !empty( $options['on_search'] ) ? $options['on_search'] : '55';
    160175    $is_tax = !empty( $options['on_tax'] ) ? $options['on_tax'] : '55';
    161176
     
    175190        return '' . $is_author . '';
    176191    }
     192    elseif(is_search()) {
     193        return '' . $is_search . '';
     194    }
    177195    elseif(is_tax()) {
    178196        return '' . $is_tax . '';
  • multiple-excerpt-lengths/trunk/readme.txt

    r1337677 r1843147  
    1616Do you have excerpts on multiple pages? Do you want to have them at different lengths?
    1717
    18 With the Multiple Excerpt Lengths plugin, you can now control the length (in words) of excerpts present at various different templates throughout your WordPress site. 
     18With the Multiple Excerpt Lengths plugin, you can now control the length (in words) of excerpts present at various different templates throughout your WordPress site.
    1919
    20 By default, **WordPress sets the length of excerpts at 55 words**. It is fairly simple to change this length – it only requires you to add a short piece of code to your functions.php file. However, once you add that code, it changes the length of **ALL** the excerpts present on your site, and you may not want that. 
     20By default, **WordPress sets the length of excerpts at 55 words**. It is fairly simple to change this length – it only requires you to add a short piece of code to your functions.php file. However, once you add that code, it changes the length of **ALL** the excerpts present on your site, and you may not want that.
    2121
    2222For example, you might want to shorten the length of the excerpts on your Front Page where you have 3 recent blog posts displayed horizontally in columns but you might not want to change the length of the excerpts on your Blog Page (which may be displaying 10 of your recent posts).
     
    5252== Changelog ==
    5353
     54= 1.1 =
     55*Added support for Search pages
     56
    5457= 1.0 =
    5558*Plugin Released
     
    5760== Upgrade Notice ==
    5861
     62= 1.1 =
     63This version adds support for Search pages
     64
    5965= 1.0 =
    6066Plugin Released
Note: See TracChangeset for help on using the changeset viewer.