コード例 #1
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
        $number_posts = $instance['number_posts'];
        $categories = $instance['categories'];
        echo $before_widget;
        if ($title != '') {
            echo $before_title . $title . $after_title;
        }
        echo '<ul>';
        $args = array();
        $args['post_type'] = 'post';
        if (!empty($categories)) {
            $args['category__in'] = $categories;
        }
        $args['posts_per_page'] = $number_posts != 0 ? $number_posts : 4;
        $query = new WP_Query($args);
        while ($query->have_posts()) {
            $query->the_post();
            global $post;
            ?>
        <li>
            <?php 
            if (has_post_thumbnail()) {
                $image = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
                $thumb = teo_resize($image, 80, 80, true);
                ?>
                <a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
">
                    <figure>
                        <img src="<?php 
                echo $thumb;
                ?>
" alt="<?php 
                the_title();
                ?>
" />
                    </figure>
                </a>
            <?php 
            }
            ?>
            <a class="post-title" href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
            <div class="info">
                <?php 
            echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ' . __('ago', 'arwyn');
            ?>
            </div>
        </li>
    <?php 
        }
        wp_reset_postdata();
        echo '</ul>';
        echo $after_widget;
    }
コード例 #2
0
                    </section>
                    <div class="normal-slider">
                        <?php 
$args = array();
$args['post_type'] = 'post';
$args['posts_per_page'] = $nrposts;
if (is_array($categories)) {
    $args['category__in'] = $categories;
}
$query = new WP_Query($args);
$i = 1;
while ($query->have_posts()) {
    $query->the_post();
    global $post;
    $thumb = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
    $resized = teo_resize($thumb, 1140, 700);
    $bginline = '';
    if ($resized != '') {
        $bginline = ' style="background-image: url(\'' . $resized . '\')"';
    }
    $likes = (int) get_post_meta($post->ID, '_teo_nr_likes', true);
    $ip = $_SERVER['REMOTE_ADDR'];
    $postIPs = get_post_meta($post->ID, '_teo_post_likes', true);
    $liked = 0;
    if ($postIPs) {
        $postIPs = unserialize($postIPs);
        if (is_array($postIPs) && in_array($ip, $postIPs)) {
            $liked = 1;
        }
    }
    ?>
コード例 #3
0
        </section>
        <section class="right-section">
            <section class="sidebar-slider">
                <?php 
$i = 1;
$args = array();
$args['post_type'] = 'post';
$args['posts_per_page'] = $nrposts;
if (is_array($categories)) {
    $args['category__in'] = $categories;
}
query_posts($args);
while (have_posts()) {
    the_post();
    $thumb = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
    $resized = teo_resize($thumb, 600, 400);
    $bginline = '';
    if ($resized != '') {
        $bginline = ' style="background-image: url(\'' . $resized . '\')"';
    }
    $likes = (int) get_post_meta($post->ID, '_teo_nr_likes', true);
    ?>
	                <article class="slide <?php 
    if ($i == 1) {
        echo 'active';
    }
    ?>
" <?php 
    echo $bginline;
    ?>
 data-slide-index="<?php 
コード例 #4
0
    $query = new WP_Query($args);
    while ($query->have_posts()) {
        $query->the_post();
        ?>
                                <div class="col-xs-4">
                                    <div class="post">
                                        <?php 
        if (has_post_thumbnail()) {
            $thumb = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
            ?>
                                            <figure>
                                                <img alt="<?php 
            the_title();
            ?>
" src="<?php 
            echo teo_resize($thumb, 220, 220);
            ?>
">
                                                <a class="overlay" href="<?php 
            the_permalink();
            ?>
">
                                                    <div class="inner">
                                                        <i class="icon-plus"></i>
                                                    </div>
                                                    <div class="background"></div>
                                                </a>
                                            </figure>
                                        <?php 
        }
        ?>
コード例 #5
0
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                    <?php 
echo '<span class="post_id" data-id="' . $post->ID . '" style="display: none"></span>';
$args = array();
$args['post_type'] = 'post';
if (is_array($categories_normal)) {
    $args['category__in'] = $categories_normal;
}
query_posts($args);
while (have_posts()) {
    the_post();
    global $post;
    $thumb = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
    $resized = teo_resize($thumb, 650, 310);
    $bginline = '';
    if ($resized != '') {
        $bginline = ' style="background-image: url(\'' . $resized . '\')"';
    }
    ?>
                        <article class="slide" <?php 
    echo $bginline;
    ?>
>
                            <div class="overlay"></div>
                            <div class="inner">
                                <div class="inner-overlay">
                                    <h2><a href="<?php 
    the_permalink();
    ?>
コード例 #6
0
<?php

global $teo_data;
$thumb = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
$resized = teo_resize($thumb, 710, 336);
$likes = (int) get_post_meta($post->ID, '_teo_nr_likes', true);
$postIPs = get_post_meta($post->ID, '_teo_post_likes', true);
$liked = 0;
$ip = $_SERVER['REMOTE_ADDR'];
if ($postIPs) {
    $postIPs = unserialize($postIPs);
    if (is_array($postIPs) && in_array($ip, $postIPs)) {
        $liked = 1;
    }
}
if ($teo_data['excerpt_type'] == 1) {
    $excerpt = wp_trim_words(get_the_content(), 70, '...');
} else {
    $excerpt = get_the_excerpt();
}
?>
<div class="homepage-post">
    <figure>
        <div class="image-overlay">
            <?php 
if (has_post_thumbnail($post->ID) && $resized != '') {
    ?>
                <img src="<?php 
    echo $resized;
    ?>
" alt="<?php 
コード例 #7
0
function teo_infinite_scroll()
{
    $page = (int) $_GET['page'];
    $template = $_GET['template'];
    $postID = isset($_GET['post_id']) ? (int) $_GET['post_id'] : '';
    $posts_per_page = get_option('posts_per_page');
    $query_string = isset($_GET['query_string']) ? $_GET['query_string'] : '';
    if ($template == 'home2' || $template == 'home3') {
        $args = '';
        if ($query_string != '') {
            $args = $query_string . '&';
        }
        $extra = '';
        //used on homepage 2 and 3 page templates
        if ($template == 'home2' && isset($postID) && $postID != '') {
            $categories_normal = get_post_meta($postID, '_home2_categories_normal', true);
            if (is_array($categories_normal) && count($categories_normal) > 0) {
                $extra = '&cat=' . implode(',', $categories_normal);
            }
        }
        if ($template == 'home3' && isset($postID) && $postID != '') {
            $categories_normal = get_post_meta($postID, '_home3_categories_normal', true);
            if (is_array($categories_normal) && count($categories_normal) > 0) {
                $extra = '&cat=' . implode(',', $categories_normal);
            }
        }
        $args .= 'post_type=post&posts_per_page=' . $posts_per_page . '&offset=' . $page * $posts_per_page . $extra;
        $query = new WP_Query($args);
        if ($query->have_posts()) {
            $json = array();
            $json['page'] = $page;
            $json['items'] = array();
            $count = 0;
            while ($query->have_posts()) {
                $query->the_post();
                global $post;
                $thumb = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
                $json['items'][$count]['image'] = teo_resize($thumb, 710, 336);
                $json['items'][$count]['title'] = get_the_title();
                $json['items'][$count]['link'] = get_permalink();
                $json['items'][$count]['author'] = get_the_author();
                $json['items'][$count]['authorLink'] = get_author_posts_url(get_the_author_meta('ID'));
                $json['items'][$count]['date'] = get_the_time(get_option('date_format'));
                $json['items'][$count]['dateLink'] = get_permalink();
                //categories code
                $categories = get_the_category();
                $separator = ', ';
                $output = '';
                if ($categories) {
                    foreach ($categories as $category) {
                        $output .= '<a href="' . get_category_link($category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", 'arwyn'), $category->name)) . '">' . $category->cat_name . '</a>' . $separator;
                    }
                    $output = trim($output, $separator);
                }
                //categories code end
                $json['items'][$count]['category'] = $output;
                if ($template == 'home2') {
                    $json['items'][$count]['excerpt'] = get_the_excerpt();
                    $json['items'][$count]['commentCount'] = get_comments_number();
                    $json['items'][$count]['heartCount'] = (int) get_post_meta($post->ID, '_teo_nr_likes', true);
                }
                $count++;
            }
            $json['totalPages'] = $query->max_num_pages;
            echo json_encode($json);
        }
        wp_reset_postdata();
    }
    die;
}