Ejemplo n.º 1
0
$switch = of_get_option('sticky_posts');
if ($switch == 'open') {
    // var_dump($switch); exit();
    $sticky = get_option('sticky_posts');
    $args = array('numberposts' => 1, 'post__in' => $sticky);
    $postQuery = get_posts($args);
    foreach ($postQuery as $post) {
        setup_postdata($post);
        ?>

<article id="post-<?php 
        the_ID();
        ?>
" class="sticky-post">
	<div class="entry-thumb"><?php 
        index_thumbnail();
        ?>
</div>
	<header>
		<h2 class="entry-title"><a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        the_title_attribute();
        ?>
" rel="bookmark"><?php 
        the_title();
        ?>
</a></h2>
		<span class="entry-meta"><i><?php 
        _e('stick post', 'pits');
Ejemplo n.º 2
0
function posts_related()
{
    global $post;
    $title = 'Related Articles';
    $limit = 4;
    $exclude_id = $post->ID;
    $posttags = get_the_tags();
    $i = 0;
    echo '<section class="related-thumb"><h3>';
    __('Related Articles', 'pits');
    echo '</h3><ul>';
    if ($posttags) {
        $tags = '';
        foreach ($posttags as $tag) {
            $tags .= $tag->name . ',';
        }
        $args = array('post_status' => 'publish', 'tag_slug__in' => explode(',', $tags), 'post__not_in' => explode(',', $exclude_id), 'caller_get_posts' => 1, 'orderby' => 'comment_date', 'posts_per_page' => $limit);
        query_posts($args);
        while (have_posts()) {
            the_post();
            echo '<li><a href="' . get_permalink() . '">';
            index_thumbnail();
            echo '<h4>' . get_the_title() . '</h4></a></li>';
            $exclude_id .= ',' . $post->ID;
            $i++;
        }
        wp_reset_query();
    }
    if ($i < $limit) {
        $cats = '';
        foreach (get_the_category() as $cat) {
            $cats .= $cat->cat_ID . ',';
        }
        $args = array('category__in' => explode(',', $cats), 'post__not_in' => explode(',', $exclude_id), 'caller_get_posts' => 1, 'orderby' => 'comment_date', 'posts_per_page' => $limit - $i);
        query_posts($args);
        while (have_posts()) {
            the_post();
            echo '<li><a href="' . get_permalink() . '" rel="bookmark">';
            index_thumbnail();
            echo '<h4>' . get_the_title() . '</h4></a></li>';
            $i++;
        }
        wp_reset_query();
    }
    /*if ( $i == 0 ){
          return false;
      }*/
    echo '</ul></section>';
}