Forums

XML-RPC does not display password protected posts (1 post)

  1. Alejandro Gonzalez
    Member
    Posted 7 months ago #

    I Worte a simple plugin to list posts from a certain category but it omits password protected posts. I added a filter to display all posts regardless of the password, but it doesn't work.

    <?php
    function xml_add_method( $methods ) {
        $methods['zio.categoryVideos'] = 'get_category_videos';
        return $methods;
    }
    
    function allPosts($where) {
    	$where .= " AND post_password like '%' ";
    	return $where;
    }
    
    function get_category_videos( $args ) {
    	global $post;
    	$args = array('numberposts' => 50,'cat' => $args );
    	add_filter('posts_where', 'allPosts');
    	$myposts = query_posts( $args );
    	$struct = array( );
    
    	foreach( $myposts as $post ) :	setup_postdata($post);
    		$id = get_the_id();
    		$guid = get_permalink();
    		$title = get_the_title();	
    
    		$struct[] = array(
    			'id'		=> $id,
    			'guid'		=> $guid,
    			'title'		=> $title,
    			'thumbnail'	=>	$thumb
    		);
    	endforeach;
    
        return $struct;
    }
    
    add_filter( 'xmlrpc_methods', 'xml_add_method' );
    ?>

Reply

You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 7 months ago by Alejandro Gonzalez
  • This topic is not resolved
  • WordPress version: 3.2.1