示例#1
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        /* Variables from settings. */
        $postnum = $instance['postnum'];
        $category = $instance['category'];
        /* Before widget (defined in functions.php). */
        echo $before_widget;
        /* Display The Widget */
        ?>
		<?php 
        if (!($reviewstyle = of_get_option('of_review_style'))) {
            $reviewstyle = 'percentage';
        } else {
            $reviewstyle = of_get_option('of_review_style');
        }
        if (!($reviewnum = of_get_option('of_review_number'))) {
            $reviewnum = '5';
        } else {
            $reviewnum = of_get_option('of_review_number');
        }
        // First loop to display only my single, most recent sticky post
        // Display the widget title if one was input
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		 <?php 
        $the_query = new WP_Query('cat=' . $category . '&showposts=' . $postnum);
        //or category_name=
        while ($the_query->have_posts()) {
            $the_query->the_post();
            ?>
		            <div class="sidepost">
		                <div class="articleinner">
		                 <div class="categories">
		                 <?php 
            echo ag_get_cats(3);
            ?>
</div>
		                     <h2><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            printf(__('Permanent Link to %s', 'framework'), get_the_title());
            ?>
"><?php 
            the_title();
            ?>
</a></h2>
		                     <span class="date"><?php 
            the_time(get_option('date_format'));
            ?>
 | <?php 
            the_author_posts_link();
            ?>
</span>
								<?php 
            /* if the post has a WP 2.9+ Thumbnail */
            if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
                ?>
		                        <div class="thumbnailarea">
		                         		<?php 
                echo ag_review_post_home(get_the_ID(), $reviewnum, $reviewstyle);
                ?>
		                         	<a class="thumblink" title="<?php 
                printf(__('Permanent Link to %s', 'framework'), get_the_title());
                ?>
" href="<?php 
                the_permalink();
                ?>
">
										<?php 
                the_post_thumbnail('blog', array('class' => 'scale-with-grid'));
                /* post thumbnail settings configured in functions.php */
                ?>
		                            </a>
		                        </div>
		                        <?php 
            }
            ?>
		                        
		                        <?php 
            if (!function_exists('has_post_thumbnail') || !has_post_thumbnail()) {
                ?>
									<a class="thumblink" title="<?php 
                printf(__('Permanent Link to %s', 'framework'), get_the_title());
                ?>
" href="<?php 
                the_permalink();
                ?>
">
										<?php 
                echo ag_review_post_home($the_query->post->ID, 3, $reviewstyle);
                ?>
		                            </a>
		                        <?php 
            }
            ?>
                                <div class="newscontent">
									<?php 
            global $more;
            $more = 0;
            if (preg_match('/<!--more/', $the_query->post->post_content)) {
                $content = apply_filters('the_content', get_the_content(__('Read More', 'framework')));
                echo $content;
            } else {
                the_excerpt();
            }
            ?>
                            	</div>
		                     <div class="clear"></div>
		                </div>
		            </div>
		        
		    <?php 
        }
        wp_reset_query();
        ?>

		<?php 
        /* After widget (defined by themes). */
        echo $after_widget;
    }
示例#2
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        /* Variables from settings. */
        $postnum = $instance['postnum'];
        $category = $instance['category'];
        /* Before widget (defined in functions.php). */
        echo $before_widget;
        /* Display The Widget */
        ?>
		<?php 
        // First loop to display only my single, most recent sticky post
        // Display the widget title if one was input
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		 <?php 
        $the_query = new WP_Query('cat=' . $category . '&showposts=' . $postnum);
        //or category_name=
        while ($the_query->have_posts()) {
            $the_query->the_post();
            ?>
		            <div class="sidepost">
		                <div class="articleinner">
		                 <div class="categories">
		                 <?php 
            echo ag_get_cats(3);
            ?>
</div>
		                     <h3><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            printf(__('Permanent Link to %s', 'framework'), get_the_title());
            ?>
"><?php 
            the_title();
            ?>
</a></h3>
		                     <span class="date"><?php 
            the_time(get_option('date_format'));
            ?>
 | <?php 
            the_author_posts_link();
            ?>
</span>
								<?php 
            /* if the post has a WP 2.9+ Thumbnail */
            if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
                ?>
		                        <div class="thumbnailarea">
		                         	<a class="thumblink" title="<?php 
                printf(__('Permanent Link to %s', 'framework'), get_the_title());
                ?>
" href="<?php 
                the_permalink();
                ?>
">
										<?php 
                the_post_thumbnail('postsidebar', array('class' => 'scale-with-grid'));
                /* post thumbnail settings configured in functions.php */
                ?>
		                            </a>
		                        </div>
		                        <?php 
            }
            ?>
		                     <?php 
            global $more;
            $more = 0;
            // echo get_the_content_unformatted_more('<span class="more-link">' . __('Read More', 'framework') . '</span>');
            the_content(__('Read More', 'framework'));
            ?>
		                     <div class="clear"></div>
		                </div>
		            </div>
		        
		    <?php 
        }
        wp_reset_query();
        ?>

		<?php 
        /* After widget (defined by themes). */
        echo $after_widget;
    }
示例#3
0
文件: twocol.php 项目: besimhu/legacy
}
?>
<div id="isonormal">

    <?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
                
    <div class="one_col isobrick">
        <div class="articleinner">

            <div class="categories">
                <?php 
        echo ag_get_cats(3);
        ?>
            </div>

            <h2 class="indextitle">
                <a href="<?php 
        the_permalink();
        ?>
" title="<?php 
        printf(__('Permanent Link to %s', 'framework'), get_the_title());
        ?>
">
                    <?php 
        the_title();
        ?>
                </a>
示例#4
0
function ag_get_posts()
{
    //permission_check();    <-- check nonce and permissions here
    global $post, $reviewstyle;
    if (!($homeposts = of_get_option('of_home_posts'))) {
        $homeposts = '6';
    }
    // get the category ID we need to load from
    $cat_id = $_POST['cat'];
    $reviewstyle = $_POST['review'];
    // show only published posts
    $args = array('post_type' => 'post', 'numberposts' => $homeposts, 'post_status' => 'publish', 'nopaging' => false, 'cat' => $cat_id);
    $posts = get_posts($args);
    // put the posts into an array
    $arr = array();
    foreach ($posts as $post) {
        setup_postdata($post);
        $entry = array();
        // get the post's ID
        $entry['id'] = $post->ID;
        // get the post's title
        $entry['title'] = $post->post_title;
        // get the post link
        $entry['link'] = get_permalink($post->ID);
        // get the post image, alt text
        if (has_post_thumbnail($post->ID)) {
            $thumb = get_post_meta($post->ID, '_thumbnail_id', false);
            // Get Image ID
            $alt = get_post_meta($thumb, '_wp_attachment_image_alt', true);
            // Alt text of image
            $thumb1 = wp_get_attachment_image_src($thumb[0], 'blog', false);
            // URL of Featured Full Image
            $thumbone = wp_get_attachment_image_src($thumb[0], 'blogonecol', false);
            // URL of Featured Full Image
            $entry['img'] = $thumb1[0];
            $entry['imgcol'] = $thumbone[0];
        }
        // get the post content, read more tag
        if (preg_match('/<!--more/', $post->post_content)) {
            $content = get_the_content(__('Read More', 'framework'));
        } else {
            $content = get_the_excerpt();
            //$content .= '<a href="'. get_permalink($post->ID) . '"><span class="more-link">'.__('Read More', 'framework').'</span></a>';
        }
        //$content = get_the_content('<span class="more-link">' . __('Read More', 'framework') . '</span>');
        $content = apply_filters('the_content', $content);
        $content = str_replace(']]>', ']]&gt;', $content);
        $entry['content'] = $content;
        // get the post comments
        $num_comments = get_comments_number($post->ID);
        // get_comments_number returns only a numeric value
        if (comments_open($post->ID) && $num_comments != 0) {
            $entry['comments'] = $num_comments;
        }
        // get the post date, using the wordpress date format
        $entry['date'] = get_the_time(get_option('date_format'));
        // get the first 3 post categories
        $cats = ag_get_cats(3);
        $entry['cats'] = $cats;
        //get the review option
        if ($reviewstyle) {
            if (!($reviewnum = of_get_option('of_review_number'))) {
                $reviewnum = '5';
            }
            $review = ag_review_post_home($post->ID, $reviewnum, $reviewstyle);
            $entry['review'] = $review;
        }
        // get the author
        $entry['author'] = '<a href="' . get_author_posts_url(get_the_author_meta("ID")) . '">' . get_the_author_meta("display_name") . '</a>';
        // store the array as a variable
        $arr[] = $entry;
    }
    // then output in json format
    header("Content-Type: application/json");
    echo json_encode($arr);
    exit;
}