• Hallo everybody,
    This plugin is very useful but unfortunately it doesn’t allow you filter content by post type.
    I looked long for a way to be able to choose the post type to pull content from.
    The author said somewhere that this would be included in a next version, but I couldn’t wait so I wrote my own quick hack to accomplish this.
    Follow these steps to add a “Post Type:” dropdown in the Edit Slider admin page. I am using FA Lite v2.3.7

    In includes/common.php
    after

    function FA_get_content( $slider_id ){
    	$options = FA_slider_options( $slider_id, '_fa_lite_content' );
    
    	$args = array();

    add

    // EDIT: add post_type support
    	$args['post_type'] = $options['post_type'];
    	//

    and after

    function FA_slider_options( $id = false, $meta_key = false ){
    	// the default values
    	$fields = array(
    		'_fa_lite_content'=>array(

    add

    // EDIT: add post type support
    		  'post_type'=>'post',
      		//

    In edit.php
    after

    <td><input type="text" name="allowed_tags" id="allowed_tags" value="<?php echo $options['_fa_lite_aspect']['allowed_tags']; ?>" class="regular-text" /><span class="note">Example to allow links and paragraphs: <a><p></span></td>
                            </tr>

    add

    <?php // EDIT: add custom type support ?>
                            <tr valign="top">
                                <th scope="row"><label for="post_type" title="<?php _e('Post type to display');?>"><?php _e('Post type to display:');?></label></th>
                                <td><select name="post_type" id="post_type">
                                <?php
                                $choices = get_post_types();
                                foreach ($choices as $choice):
                                  $selected = ($choice==$options['_fa_lite_content']['post_type']) ? 'selected="selected"' : ''; ?>
                                    <option value="<?php echo $choice;?>" <?php echo $selected;?>><?php echo $choice;?></option>
                                <?php endforeach;?>
                                </select></td>
                            </tr>
    <?php // ?>

    That did the trick for me.
    I hope this helps someone with the same issue and that the author includes this functionality in the next release.
    Thanks to the author for this plugin!

    http://wordpress.org/extend/plugins/featured-articles-lite/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey!!! Nice work. This is exactly what I was looking for. I couldn’t find a way to post images into a slider from using the Custom Post Types UI.

    This worked great. Thanks so much for this contribution.

    This person needs to be notified to update the installation using your mods.

    Nicely Done.

    Hot! You just made one of my favorite plug-ins even better, just what I needed tonight to meet a new demand. Many, many thanks! Gotta love super clear directions 🙂

    Since this sort of coding is a stretch for me , any ideas on how to get it to recognize a custom taxonomy structure for a CPT as well?

    jpisanu

    (@jpisanu)

    Hi there, GREAT way of adding custom posts type support to this great plugin.
    In my case I couldn’t find the <td><input type=”text” name=”allowed_tags”… (maybe the plugin is updated already and it’s different now.

    So the thing is that I’m getting the custom post types listed on it’s settings but after setting my custom post type, the regular posts are still shown on the page.

    Any ideas of where the problem could be?

    Thanks!!

    Thanks A Lot… !!!!!
    This works for me… Saved my 1 day….

    @jpisanu If you are using this plugin new version this trick not work….

    Replace this whole function.

    function FA_get_content( $slider_id ){
    	$options = FA_slider_options( $slider_id, '_fa_lite_content' );
    
    	$args = array();
    	$args['post_type'] = $options['post_type'];
    	$args['numberposts'] = $options['num_articles'];
    	$args['order'] = 'DESC';
    
    	if( $options['displayed_content'] == 2 ){
    		if( isset($options['display_pages'][0]) )
    			$args['include'] = implode(',', $options['display_pages']);
    	}else{
    		if( isset($options['display_from_category'][0]) )
    			$args['category'] = implode(',',$options['display_from_category']);
    	}
    
    	/* get posts depending on what order was chosen ( by date, by comment count or by meta key ) */
    	switch ( $options['display_order'] ){
    		case 1: default:
    			$args['orderby'] = 'post_date';
    		break;
    		case 2:
    			$args['meta_query'] = array(array(
    				'key'=>'_fa_featured',
    				'value'=>'"'.$slider_id.'"',
    				'compare'=>'LIKE'
    			));
    			$args['orderby'] = 'post_date';
    			//$args['meta_key'] = '_fa_featured';
    			//$args['meta_value'] = 1;
    		break;
    		case 3:
    			$args['orderby'] = 'comment_count post_date';
    		break;
    		case 4:
    			$args['orderby'] = 'rand';
    		break;
    	}	
    
    	if( $options['displayed_content'] == 1 ){
    		$postslist = get_posts($args);
    	}else{
    		$args['sort_order'] = $options['display_order'] == 4 ? 'RAND()' : 'DESC';
    		if( $options['display_order'] == 3 ){
    			$args['sort_column'] = 'comment_count DESC, post_date';
    		}else if( $options['display_order'] == 4 ){
    			$args['sort_column'] = '';
    		}else{
    			$args['sort_column'] = $args['orderby'];
    		}
    		$postslist = get_pages($args);
    	}
    	// remove captions and unwanted HTML tags
    	$aspect_opt = FA_slider_options( $slider_id, '_fa_lite_aspect' );
    	foreach($postslist as $k=>$v){
    		$content = $v->post_content;
    		// remove shortcodes from content
    	    $string = strip_shortcodes( $content );
    	    // remove all HTML tags except links
    	    $string = strip_tags($string,$aspect_opt['allowed_tags']);
    	    //store the slider stripped text into a different variable
    		$postslist[$k]->FA_post_content = $string;
    	}
    
    	return $postslist;
    }

    @ajay – which function would i have to replace to get it working with the new version?

    i cannot understand why the developer would omit such a crucial piece…

    Plugin Author Constantin Boiangiu

    (@constantinboiangiu)

    It’s not omitted it just isn’t a Lite feature. PRO version of the plugin has custom posts and taxonomies capabilities.
    The above modification should be done in file includes/common.php.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Featured Articles Lite] choose custom post type’ is closed to new replies.