Beispiel #1
0
/**
 * Api method for retrieving posts
 *
 * @param string $page 
 * @param string $posts_per_page 
 * @return void
 * @author Armando Sosa
 */
function api_get_post($id)
{
    global $api;
    $posts = array();
    // query parameters
    $options = array('post_status' => 'publish', 'p' => $id);
    if ($posts_per_page > 0) {
        $options['posts_per_page'] = $posts_per_page;
    }
    // query for the posts
    query_posts($options);
    global $wp_query;
    $max_pages = $wp_query->max_num_pages;
    // this is the meta information that we'll pass to the app
    $object['meta'] = array('max_pages' => $max_pages, 'current_page' => absint(get_query_var('paged')));
    // loop trough the posts and propagate the object array
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            // this is a hack to get full posts always
            global $more, $post;
            $more = true;
            // this is to get the content with all the filters without echoing it.
            $content = str_replace(']]>', ']]>', apply_filters('the_content', get_the_content('')));
            // populate the object;
            $postObject = array('id' => $post->ID, 'author_id' => $post->post_author, 'author_display_name' => get_the_author(), 'title' => get_the_title(), 'post_date' => $post->post_date, 'permalink' => get_permalink(), 'content' => $content, 'excerpt' => get_the_excerpt(), 'featured_image' => PostsHelper::getImage(), 'comments_open' => comments_open($post->ID), 'comment_count' => get_comments_number(), 'shortlink' => '', 'categories' => get_the_category());
            // if a shortlink exists, let's use that.
            if (function_exists('wp_get_shortlink')) {
                $postObject['shortlink'] = wp_get_shortlink($post->ID, 'post');
            } else {
                $postObject['shortlink'] = $postObject['permalink'];
            }
            $object['posts'][] = $postObject;
        }
    }
    $api->jsonize($object);
}
Beispiel #2
0
</h1>
	
	</div>
	
</div>

<div id="main-content" class="container">

	<div class="row">
	
		<div id="content-primary" class="col-md-9">
		<?php 
    // Start the Loop.
    get_template_part('content', get_post_format());
    // Previous/next post navigation.
    PostsHelper::theme_post_nav();
    // If comments are open or we have at least one comment, load up the comment template.
    if (comments_open() || get_comments_number()) {
        comments_template();
    }
    ?>
		</div><!-- #content-primary -->
	
		<div id="content-sidebar" class="col-md-3">
		
			<?php 
    get_sidebar();
    ?>
		
		</div><!-- #content-sidebar -->
	
Beispiel #3
0
			</h1>
		</header><!-- .archive-header -->

		<?php 
    // Start the Loop.
    while (have_posts()) {
        the_post();
        /*
         * Include the post format-specific template for the content. If you want to
         * use this in a child theme, then include a file called called content-___.php
         * (where ___ is the post format) and that will be used instead.
         */
        get_template_part('content', get_post_format());
    }
    // Previous/next page navigation.
    PostsHelper::theme_paging_nav('array');
} else {
    // If no content, include the "No posts found" template.
    get_template_part('content', 'none');
}
?>
		</div><!-- #content-primary -->
		
		<div id="content-sidebar" class="col-md-3">
		
			<?php 
get_sidebar();
?>
		
		</div><!-- #content-sidebar -->
		
Beispiel #4
0
PostsHelper::theme_post_thumbnail();
?>

	<header class="entry-header">
		<?php 
if (is_single()) {
    the_title('<h1 class="entry-title">', '</h1>');
} else {
    the_title('<h1 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h1>');
}
?>

		<div class="entry-meta">
			<?php 
if ('post' == get_post_type()) {
    PostsHelper::theme_posted_on();
}
if (!post_password_required() && (comments_open() || get_comments_number())) {
    ?>
			<span class="comments-link"><?php 
    comments_popup_link(__('Leave a comment', 'rrtb'), __('1 Comment', SITE_TEXT_DOMAIN), __('% Comments', SITE_TEXT_DOMAIN));
    ?>
</span>
			<?php 
}
edit_post_link(__('Edit', SITE_TEXT_DOMAIN), '<span class="edit-link">', '</span>');
?>
		</div><!-- .entry-meta -->
	</header><!-- .entry-header -->

	<?php