WordPress.org

Ready to get started?Download WordPress

Forums

Recent Posts with Excerpts
Link widget title to any page (1 post)

  1. fallenartist
    Member
    Posted 1 year ago #

    Hi,
    Thanks for excellent and lightweight plugin - just what I needed. However, I think the limitation to link the widget's title just to home page is a limitation. In situations where users want to use the plugin with certain categories, it seems natural they would want to point to a specific page (like "News" page template in my case).

    So, I have modified the plugin slightly to allow that. Below are my modifications (just snippets where changes were made). I'm not an expert, so it could possibly be done better. Please use it freely if you like:

    echo $before_widget;
    if ( !empty($title) ) {
    	if (!empty($instance['postlink']))  {
    		$link = get_page_link($instance['postlink']);
    		$before_title .= '<a href="'.$link.'">';
    		$after_title .= '</a>';
    	}
    	echo $before_title.$title.$after_title;
    }
    function form( $instance ) {
    	//Defaults
    	$instance = wp_parse_args( (array) $instance, array(
    		'title' => __('Recent Posts', 'recent_posts_with_excerpts'),
    		'numposts' => 5,
    		'numexcerpts' => 5,
    		'date' => get_option('date_format'),
    		'more_text' => __('more...', 'recent_posts_with_excerpts'),
    		'words' => '55',
    		'tags' => '<p><div><span><br><img><a><ul><ol><li><blockquote><cite><em><i><strong><b><h2><h3><h4><h5><h6>',
    		'cat' => 0,
    		'tag' => '',
    		'postlink' => 0,
    		'thumb' => 0,
    		'thumbposition' => 'above',
    		'thumbsize' => ''));
    <p>
    	<label for="<?php echo $this->get_field_id('postlink'); ?>"><?php _e('Link widget title to post or page:', 'recent_posts_with_excerpts'); ?>
    		<?php wp_dropdown_pages(array('name' => $this->get_field_name('postlink'), 'show_option_all' => __('None'), 'hide_empty'=>0, 'hierarchical'=>1, 'selected'=>$instance['postlink'])); ?>
    	</label>
    </p>

    http://wordpress.org/extend/plugins/recent-posts-with-excerpts/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by fallenartist
  • This topic is not a support question
  • WordPress version: 3.5.1