function post_loop_views($postID) { $count = getPostViews($postID); echo " • " . $count . "浏览"; }
<?php $ajaxVal = $_GET['ajax']; if ($ajaxVal == "getPostViews") { setPostViews($_GET['postID']); echo getPostViews($_GET['postID']); }
?> <li id="<?php echo $post->ID; ?> "> <a href="<?php echo the_permalink(); ?> " title="Enlace Permanente a <?php echo the_title(); ?> (<?php echo getPostViews($post->ID); ?> visitas)"> <div class="cont_text"> <h4> <?php $the_title = get_the_title(); if (mb_strlen($the_title, 'utf8') > 75) { $last_space = strrpos(substr($the_title, 0, 75), ' '); // find the last space within 35 characters $the_title = substr($the_title, 0, $last_space) . '...'; } echo $the_title; ?> </h4> <span class='duration_rand'><strong><?php
<?php get_header(); $post_id = get_the_ID(); setPostViews($post_id); $post_view = getPostViews($post_id); ?> <div id="core_padding"> <div id="core_padding_inner"> <div class=" container widecontainer core_section_top_container"> <div class="row core_section_top_row wlt_main_2colsleft"> <div id="core_inner_wrap" class="clearfix"> <article class="col-md-12 col-sm-12" id="core_middle_column"><div class="core_middle_wrap"><div id="core_ajax_callback"></div> <a name="toplisting"></a> <a name="toplisting"></a> <div class="row" style="margin-top:10px;"> <div class="col-md-6"> <h1 style="margin-top:0px;"><a href="<?php echo get_the_permalink(); ?> "><span><?php echo get_the_title(); ?> </span></a></h1> </div> <div class="col-md-6 pull-left" > <span id='timeleft_30971449416771686923'></span> <?php $cudate = get_post_meta($post_id, "expire_time", true); $next_date = strtotime($cudate);
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); /* Variables from settings. */ $numposts = $instance['numposts']; $facebook = $instance['facebook']; $social = $instance['social']; $fbfooter = $instance['fbfooter']; $feed = $instance['feed']; $faces = $instance['faces']; $fburl = $instance['fburl']; /* Before widget (defined in functions.php). */ echo $before_widget; /* Display The Widget */ ?> <?php /* Display the widget title & subtitle if one was input (before and after defined by themes). */ if ($title) { echo '<h3 class="widget-title">' . $title . '</h3>'; } ?> <?php if ($social == 'facebook') { $twocol = ''; } else { $twocol = 'twocol'; } ?> <div class="tabswrap"> <ul class="tabs <?php echo $twocol; ?> "> <li><a class="active" href="#tab1"><?php _e('Popular', 'framework'); ?> </a></li> <li><a href="#tab2"><?php _e('Recent', 'framework'); ?> </a></li> <?php if ($social == 'facebook') { ?> <li><a href="#tab3"><?php _e('Facebook', 'framework'); ?> </a></li> <?php } ?> </ul> <div class="clear"></div> <ul class="tabs-content"> <!-- First Tab ================================================--> <li id="tab1" class="active"> <?php query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC&ignore_sticky_posts=1&posts_per_page=' . $numposts); ?> <?php if (have_posts()) { while (have_posts()) { the_post(); ?> <div class="tabpost"> <div class="featuredimagewidget thumbnailarea"> <?php if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it. ?> <a class="thumblink" href="<?php the_permalink(); ?> "> <?php the_post_thumbnail('tinyfeatured'); ?> </a> <?php } ?> </div> <p><strong><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></strong></p> <p class="views"><?php echo getPostViews(get_the_ID()); ?> </p> <div class="clear"></div> </div> <?php } } wp_reset_query(); ?> </li> <!-- Second Tab ================================================--> <li id="tab2"> <?php query_posts('ignore_sticky_posts=1&posts_per_page=' . $numposts); if (have_posts()) { while (have_posts()) { the_post(); ?> <div class="tabpost"> <div class="featuredimagewidget thumbnailarea"> <?php if (has_post_thumbnail()) { // check if the post has a Post Thumbnail assigned to it. ?> <a class="thumblink" href="<?php the_permalink(); ?> "> <?php the_post_thumbnail('tinyfeatured'); ?> </a> <?php } ?> </div> <p><strong><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></strong></p> <p class="views"><?php the_time(get_option('date_format')); ?> </p> <div class="clear"></div> </div> <?php } } wp_reset_query(); ?> </li> <?php if ($social == 'facebook') { ?> <!-- Third Tab ================================================--> <li id="tab3"> <div id="fb-root"></div> <script type="text/javascript">(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like-box" data-href="<?php echo $fburl; ?> " data-width="260" data-colorscheme="<?php echo $fbfooter == 'yes' ? 'dark' : 'light'; ?> " data-show-faces="<?php echo $faces; ?> " data-border-color="<?php echo $fbfooter == 'yes' ? '#222' : '#fff'; ?> " data-stream="<?php echo $feed; ?> " data-header="false"></div> </li> <?php } ?> </ul> <div class="clear"></div> </div> <?php /* After widget (defined by themes). */ echo $after_widget; }
</div> <div class="entry-top-meta"> <div class="like-button entry-top-meta-el"> <?php echo getPostLikeLink($post_id); ?> </div> <div class="comments-count entry-top-meta-el"> <i class="fa fa-comment-o"></i><span class="comments-count-num"> <?php comments_number('0', '1', '%'); ?> </span> </div> <div class="views-count entry-top-meta-el"> <i class="fa fa-eye"></i><span class="views-count-num"> <?php echo getPostViews($post_id); ?> </span> </div> </div> </div> <div class="entry-content"> <?php the_content(); ?> <?php wp_link_pages(array('before' => '<div class="page-links">' . esc_html__('Pages:', 'opengamer_theme'), 'after' => '</div>')); ?>
function the_view() { echo getPostViews(get_the_ID()); if (is_single()) { setPostViews(get_the_ID()); } }
function get_page_list() { $cat = $_GET['cat']; $page = $_GET['page']; $posts_per_page = $_GET['posts_per_page']; if (!is_null($cat) && $cat != 0 && !is_null($page)) { $args = array("category__in" => array($cat), "paged" => $page, "posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc'); } else { if (!is_null($cat) && $cat != 0 && is_null($page)) { $args = array("category__in" => array($cat), "posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc'); } else { if ((is_null($cat) || $cat == 0) && !is_null($page)) { $args = array("paged" => $page, "posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc'); } else { $args = array("posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc'); } } } if (!is_null($cat)) { $posts = get_posts('post_status=publish&numberposts=-1&category=' . $cat); $count_total = count($posts); } else { $cat_case = get_category_by_slug('case'); $cat_interview = get_category_by_slug('interview'); $cat_personnel = get_category_by_slug('personnel'); $cat_special = get_category_by_slug('special-column'); $cat_news = get_category_by_slug('news'); $posts = get_posts('post_status=publish&numberposts=-1&category=' . $cat_case . ',' . $cat_interview . ',' . $cat_personnel . ',' . $cat_special . ',' . $cat_news); $count_total = count($posts); } $the_query = new WP_Query($args); $resultData = new resultData(); $resultList = array(); $resultData->count_total = $count_total; while ($the_query->have_posts()) { $the_query->the_post(); $post = new postData(); $post->title_plain = get_the_title(); $post->url = get_permalink(); $post->thumbnail = get_template_directory_uri() . "/timthumb.php?src=" . post_thumbnail_src() . "&h=168&w=224&zc=1"; $post->excerpt = get_the_excerpt(); $post->date = get_the_date('20y-m-d'); $post->author_name = get_author_name(); $post->views = getPostViews(get_the_ID()); $the_post_category = get_the_category(get_the_ID()); $post->category_name = $the_post_category[0]->cat_name; $the_post_category = get_the_category(get_the_ID()); $catSlug = $the_post_category[0]->slug; $post->category_slug = $catSlug; $resultList[] = $post; } $resultData->posts = $resultList; header("Content-type: application/json"); echo json_encode($resultData); wp_reset_query(); die; }
function post_meta($disqus_shortname, $author, $date, $comments, $views, $category) { $out = ''; if ($author == 'view') { $out .= '<div><span>' . __('By', 'corporative') . '</span> ' . get_the_author_link() . '</div>'; } if ($date == 'view') { $out .= '<div><span>' . __('In', 'corporative') . '</span> ' . get_the_time('F j, Y') . '</div>'; } if ($category == 'view') { $out .= '<div><span>' . __('On', 'corporative') . '</span> ' . get_the_category_list(', ') . '</div>'; } if ($comments == 'view') { $out .= '<div>' . comments_count($disqus_shortname) . '</div>'; } if ($views == 'view') { $out .= '<div>' . getPostViews(get_the_ID()) . '</div>'; } return $out; }
function ct_get_post_meta($ct_postid, $ct_comments, $ct_views, $ct_likes) { global $post; ?> <?php if ($ct_comments == 1) { ?> <?php if (comments_open()) { ?> <span class="meta-comments"> <i class="icon-comment"></i> <?php comments_popup_link(__('0', 'color-theme-framework'), __('1', 'color-theme-framework'), __('%', 'color-theme-framework')); ?> </span><!-- .meta-comments --> <?php } ?> <?php } ?> <?php if ($ct_views == 1) { ?> <span class="meta-views" title="<?php _e('Views', 'color-theme-framework'); ?> "> <i class="icon-eye-open"></i> <?php echo getPostViews($ct_postid); ?> </span><!-- .meta-views --> <?php } ?> <?php if ($ct_likes == 1) { ?> <span class="meta-likes" title="<?php _e('Likes', 'color-theme-framework'); ?> "> <?php getPostLikeLink($ct_postid); ?> </span><!-- .meta-likes --> <?php } ?> <?php $post_type = get_post_meta($post->ID, 'ct_mb_post_type', true); if ($post_type == 'review_post') { ct_get_rating_stars(); } if ($post_type == 'review_post_numeric') { ct_get_rating_numeric(); } ?> <?php }
function widget($args, $instance) { extract($args); echo $before_widget; if ($instance['title'] != "") { echo $before_title . $instance['title'] . $after_title; } else { echo $before_title . "热门文章" . $after_title; } echo "<ul>"; if ($instance['Num'] != "") { $popular = new WP_Query('orderby=comment_count&showposts=' . $instance['Num'] . ''); } else { $popular = new WP_Query('orderby=comment_count&showposts=8'); } while ($popular->have_posts()) { $popular->the_post(); ?> <li class="article"> <h2><a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> " target="_blank"><?php the_title(); ?> </a></h2> <span>日期:<?php the_time('Y-m-d'); ?> 评论:<?php comments_number('0', '1', '%'); ?> 浏览:<?php echo getPostViews(get_the_ID()); ?> </span> </li> <?php } echo "</ul>"; echo $after_widget; }
<article class="post_item' . ($show_image == 0 ? ' no_thumb' : ' with_thumb') . ($post_number == 1 ? ' first' : '') . '"> '; if ($show_image) { $post_thumb = getResizedImageTag($post_id, 75, 75); if ($post_thumb) { $output .= ' <div class="post_thumb">' . $post_thumb . '</div> '; } } $output .= ' <h5 class="post_title"><a href="' . $post_link . '">' . $post_title . '</a></h5> '; if ($show_counters) { if ($show_counters == 'views') { $post_counters = getPostViews($post_id); $post_counters_icon = 'eye'; } else { if ($show_counters == 'likes') { $post_counters = getPostLikes($post_id); $post_counters_icon = 'heart-1'; } else { if ($show_counters == 'stars' || $show_counters == 'rating') { $post_counters = marksToDisplay(get_post_meta($post_id, $post_rating, true)); $post_counters_icon = 'star-1'; } else { $post_counters = get_comments_number($post_id); $post_counters_icon = 'comment-1'; } } }
function print_post($para_print_post, $cate_slug) { $approveCom = wp_count_comments($para_print_post['id']); $output .= '<article class="newsCenter" id="post-' . $para_print_post['id'] . '" style="border-top: 2px solid ' . get_color($cate_slug) . ';">'; $output .= '<div class="autNewsCt row">'; $output .= '<div class="top-box-article"> '; $output .= '<span class="ctnAutCt col-md-10 col-sm-10 col-xs-9 col-lg-5">'; $output .= '<h4>'; $output .= '<a href="' . $para_print_post['link'] . '">' . $para_print_post['title'] . '</a>'; $output .= '</h4>'; $output .= '</span>'; $output .= '<a class="date-post" href="' . $para_print_post['link'] . '">' . $para_print_post['date'] . '</a>'; $output .= '<div class="icon-list-btn col-lg-4">'; $output .= '<ul>'; $output .= '<li>'; $output .= '<span title="Cảm ơn"><i class="fa fa-heart"></i></span>'; $output .= '<br/>'; $output .= '<span class="value-btn">' . getPostLoves($para_print_post['id']) . '</span>'; $output .= '</li>'; $output .= '<li>'; $output .= '<a title="Chia sẻ" class="btn-shareface" data-gtmname="chia-se" rel="nofollow" target="_blank" href="http://www.facebook.com/sharer.php?u=' . $para_print_post['link'] . '">'; $output .= '<span><i class="fa fa-share-alt"></i></span>'; $output .= '<br/>'; $output .= '<span class="value-btn">' . get_post_shares($para_print_post['id']) . '</span>'; $output .= '</a>'; $output .= '</li>'; $output .= '<li>'; $output .= '<span title="Lượt xem" ><i class="fa fa-eye"></i></i></span>'; $output .= '<br/>'; $output .= '<span class="value-btn">' . getPostViews($para_print_post['id']) . '</span>'; $output .= '</li>'; $output .= '</ul>'; $output .= '</div>'; $output .= '</div>'; $output .= '<div class="bottom-box-article">'; $output .= '<a class="link-post-content" href="' . $para_print_post['link'] . '">'; $output .= '<p>' . $para_print_post['except'] . '</p>'; $output .= '</a>'; $output .= '<div class="imgArtCt">'; $output .= '<em>'; $output .= '<a href="' . $para_print_post['link'] . '"><img src="' . $para_print_post['image_link'] . '" alt="' . $para_print_post['title'] . '"></a>'; $output .= '</em>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</article>'; echo $output; }
function accesspress_mag_home_posted_on_cb() { global $post; $show_post_views = of_get_option('show_post_views'); $show_comment_count = of_get_option('show_comment_count'); $show_post_date = of_get_option('post_show_date'); $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; if (get_the_time('U') !== get_the_modified_time('U')) { $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>'; } $time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date())); if ($show_post_date == 1) { $posted_on = sprintf(_x('%s', 'post date', 'accesspress-mag'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>'); } else { $posted_on = ''; } echo '<span class="posted-on">' . $posted_on . '</span>'; if ($show_comment_count == 1) { $post_comment_count = get_comments_number($post->ID); echo '<span class="comment_count"><i class="fa fa-comments"></i>' . esc_attr($post_comment_count) . '</span>'; } if ($show_post_views == 1) { echo '<span class="apmag-post-views"><i class="fa fa-eye"></i>' . getPostViews(get_the_ID()) . '</span>'; } }
/** @see WP_Widget::widget */ function widget($args, $instance) { extract($args); //these are our widget options $title = $instance['title']; $count = $instance['count']; //get recent posts query_posts(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $count, 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC')); echo $before_widget; ?> <div class="clearfix"> <div class="header_left"> <?php if ($title) { echo $before_title . $title . $after_title; } ?> </div> <div class="header_right"> <a href="#" id="most_viewed_prev" class="scrolling_list_control_left icon_small_arrow left_black"></a> <a href="#" id="most_viewed_next" class="scrolling_list_control_right icon_small_arrow right_black"></a> </div> </div> <div class="scrolling_list_wrapper"> <ul class="scrolling_list most_viewed"> <?php if (have_posts()) { while (have_posts()) { the_post(); ?> <li class="icon_small_arrow right_black"> <a href="<?php the_permalink(); ?> " class="clearfix" title="<?php the_title(); ?> "> <span class="left"> <?php the_title(); ?> </span> <span class="number"> <?php echo getPostViews(get_the_ID()); ?> </span> </a> <abbr title="<?php the_time('c'); ?> " class="timeago"><?php the_time('c'); ?> </abbr> </li> <?php } } wp_reset_query(); ?> </ul> </div> <?php echo $after_widget; }
function mom_blog_post($style = 1, $nexcerpt, $class) { global $post; $post_meta_hp = mom_option('post_meta_hp'); if ($post_meta_hp == 1) { $post_head = mom_option('post_head'); $post_head_author = mom_option('post_head_author'); $post_head_date = mom_option('post_head_date'); $post_head_cat = mom_option('post_head_cat'); $post_head_commetns = mom_option('post_head_commetns'); $post_head_views = mom_option('post_head_views'); } else { $post_head = 1; $post_head_author = 1; $post_head_date = 1; $post_head_cat = 1; $post_head_commetns = 1; $post_head_views = 1; } if ($style == 'large') { ?> <article <?php post_class('blog-post-big nb1 ' . $class); ?> itemscope="" itemtype="http://schema.org/Article"> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"> <a href="<?php the_permalink(); ?> "> <?php $thumbsize = 'blogb-thumb'; if (mom_option('site_width') == 'wide') { $thumbsize = 'big-thumb-hd'; } mom_post_image_full($thumbsize); ?> <span class="post-format-icon"></span> </a> </figure> <?php } ?> <h2 itemprop="name"> <a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_author != 0) { ?> <div class="author-link"> <?php _e('Posted by ', 'framework'); ?> <a itemprop="author" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author"><?php echo get_the_author(); ?> </a> </div> <?php } ?> <?php if ($post_head_date != 0) { ?> <span>|</span><time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_cat != 0) { ?> <div class="cat-link"> <span>|</span><?php _e('in :', 'framework'); ?> <?php the_category(', '); ?> </div> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <span>|</span><a href="<?php the_permalink(); ?> "> <?php comments_number(__('0 comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> <?php if ($post_head_views != 0) { ?> <div class="post-views"> <span>|</span><?php echo getPostViews(get_the_ID()); ?> </div> <?php } ?> </div> <?php } ?> <div class="entry-content"> <?php $excerpt = get_the_excerpt(); if ($excerpt == false) { $excerpt = get_the_content(); } if ($nexcerpt != '') { echo wp_html_excerpt(strip_shortcodes($excerpt), $nexcerpt, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), 304, '...'); } ?> </div> <?php if (is_rtl()) { ?> <a class="read-more" href="<?php the_permalink(); ?> "><?php _e('Read more', 'framework'); ?> <i class="fa-icon-angle-double-left"></i></a> <?php } else { ?> <a class="read-more" href="<?php the_permalink(); ?> "><?php _e('Read more', 'framework'); ?> <i class="fa-icon-angle-double-right"></i></a> <?php } ?> </article> <?php } elseif ($style == 'grid') { $dateformat = mom_option('date_format'); ?> <li <?php post_class(); ?> itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name" class="cat-list-title"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="cat-list-meta entry-meta"> <?php if ($post_head_author != 0) { ?> <div class="author-link"> <?php _e('Posted by', 'framework'); ?> <a itemprop="author" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author"><?php echo get_the_author(); ?> </a> </div> <?php } ?> <?php if ($post_head_date != 0) { ?> <span>|</span><time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><?php _e('Date: ', 'framework'); the_time($dateformat); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <span>|</span><a href="<?php the_permalink(); ?> "> <?php comments_number(__('0 comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> <?php if ($post_head_views != 0) { ?> <div class="post-views"> <span>|</span><?php echo getPostViews(get_the_ID()); ?> </div> <?php } ?> </div> <?php } ?> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } ?> <h2 itemprop="name" class="cat-grid-title"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content cat-grid-meta"> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } echo wp_html_excerpt(strip_shortcodes($excerpt), 105, '...'); ?> ... </p> </div> <?php if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <div class="entry-content cat-list-meta"> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } echo wp_html_excerpt(strip_shortcodes($excerpt), 200, '...'); ?> ... </p> </div> <?php if ($post_head != 0) { ?> <div class="cat-grid-meta entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><?php the_time($dateformat); ?> </time> <?php } ?> <?php if ($post_head_author != 0) { ?> <div class="author-link"> |<?php _e(' by ', 'framework'); ?> <a itemprop="author" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author"><?php echo get_the_author(); ?> </a> </div> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> |<a href="<?php the_permalink(); ?> "> <?php comments_number(__('0 comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> <?php if (is_rtl()) { ?> <a class="read-more" href="<?php the_permalink(); ?> "><?php _e('Read more', 'framework'); ?> <i class="fa-icon-angle-double-left"></i></a> <?php } else { ?> <a class="read-more" href="<?php the_permalink(); ?> "><?php _e('Read more', 'framework'); ?> <i class="fa-icon-angle-double-right"></i></a> <?php } ?> </div> </li> <?php } else { ?> <article <?php post_class('blog-post nb1 ' . $class); ?> itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name"> <a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </h2> <?php if ($post_head != 0) { ?> <div class="entry-meta"> <?php if ($post_head_author != 0) { ?> <div class="author-link"> <?php _e('Posted by ', 'framework'); ?> <a itemprop="author" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author"><?php echo get_the_author(); ?> </a> </div> <?php } ?> <?php if ($post_head_date != 0) { ?> <span>|</span><time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><?php mom_date_format(); ?> </time> <?php } ?> <?php if ($post_head_cat != 0) { ?> <div class="cat-link"> <span>|</span><?php _e('in :', 'framework'); ?> <?php the_category(', '); ?> </div> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <span>|</span><a href="<?php the_permalink(); ?> "> <?php comments_number(__('0 comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> <?php if ($post_head_views != 0) { ?> <div class="post-views"> <span>|</span><?php echo getPostViews(get_the_ID()); ?> </div> <?php } ?> </div> <?php } ?> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"> <a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('blog-thumb'); ?> <span class="post-format-icon"></span> </a> </figure> <?php } ?> <div class="entry-content"> <?php $excerpt = get_the_excerpt(); if ($excerpt == false) { $excerpt = get_the_content(); } if ($nexcerpt != '') { echo wp_html_excerpt(strip_shortcodes($excerpt), $nexcerpt, '...'); } else { echo wp_html_excerpt(strip_shortcodes($excerpt), 170, '...'); } ?> </div> <?php if (is_rtl()) { ?> <a class="read-more" href="<?php the_permalink(); ?> "><?php _e('Read more', 'framework'); ?> <i class="fa-icon-angle-double-left"></i></a> <?php } else { ?> <a class="read-more" href="<?php the_permalink(); ?> "><?php _e('Read more', 'framework'); ?> <i class="fa-icon-angle-double-right"></i></a> <?php } ?> </article> <?php } }
function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); if (!empty($title)) { echo $before_title . $title . $after_title; } ?> <div class="block-item-small-view popularviewbg"><?php $custom_values = get_post_meta($post->ID, 'post_views_count'); ?> <ol> <?php $args = array('meta_key' => 'post_views_count', 'post_status' => 'publish', 'post_type' => 'post', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'posts_per_page' => '7'); query_posts($args); if (have_posts()) { while (have_posts()) { the_post(); ?> <li class="block-image-viewed"> <span class="block-image-viewed-l"> <a href='<?php the_permalink(); ?> ' title='<?php the_title(); ?> '> <?php the_title(); ?> </a> <span class="block-image-viewed-views"> - <?php echo getPostViews(get_the_ID()); ?> <?php _e("views", "mm"); ?> </span></span> <span class="block-image-viewed-r"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <?php the_post_thumbnail('popular-thumb'); ?> </a> </span> </li> <?php } } else { //Do Whatever } wp_reset_query(); ?> </ol> </div> <?php echo $after_widget; }
$current_time = strtotime(date("Y-m-d H:i:s")); $data['sold_out'] = null; if ($next_date <= $current_time) { $max_price = get_maxprice($post_id); if ($max_price == 0) { $next_new_time = $next_date + 60 * 5; $new_date = date("Y-m-d H:i:s", $next_new_time); update_post_meta($post_id, "expire_time", $new_date); } else { update_post_meta($post_id, "sold_out", "yes"); $win_data = get_winner_data($post_id); $win_user_id = $win_data['uid']; $msg = "You win product with your bid " . $win_data['price']; $headers = 'From: Online Auction <*****@*****.**>' . "\r\n"; $attachments = ""; $data['sold_out'] = 1; $data['winner_price'] = $win_data['price']; $data['winner_uid'] = $win_data['uid']; $data['winner_name'] = get_the_author_meta("first_name", $win_user_id) . " " . get_the_author_meta("last_name", $win_user_id); } } $data['max_bid_userid'] = 1; $data['number_of_bids'] = get_number_of_bids($post_id); $data['max_bid'] = get_maxprice($post_id); $data['get_nextbid_price'] = get_nextbid_price($post_id); $data['post_view'] = getPostViews($post_id); echo json_encode($data); ?>
" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?> "><?php the_title(); ?> </a></h2> <p class="post-meta"> 作者 <a class="post-author"><?php the_author(); ?> </a> <?php get_post_meta_info(get_the_ID()); echo "阅读次数 " . getPostViews(get_the_ID()); ?> </p> </header> <div class="post-description"> <?php if (has_post_thumbnail()) { ?> <?php the_post_thumbnail('thumbnail', array('class' => 'thumb')); ?> <?php } ?> <?php
?> <?php } else { ?> <img src="<?php bloginfo('template_url'); ?> /icon/<?php echo rand(1, 6); ?> .jpg" class="thumb" /> <?php } ?> <?php the_content('已经有' . getPostViews(get_the_ID()) . '人阅读了余下的内容,点击阅读 »'); ?> </div> </section> <?php } ?> <?php pagination($query_string); ?> </div> <?php } else { ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn'there.</p>
_e('Related posts', 'themerex'); ?> </h3> </div> <?php $i = 0; foreach ($recent_posts as $recent) { $i++; $recent['post_format'] = get_post_format($recent['ID']); $recent['post_icon'] = getPostFormatIcon($recent['post_format']); $recent['post_link'] = get_permalink($recent['ID']); $recent['comments_link'] = $counters == 'comments' ? get_comments_link($recent['ID']) : $recent['post_link']; $recent['post_thumb'] = getResizedImageTag($recent['ID'], 310, 310); $recent['attachment'] = wp_get_attachment_url(get_post_thumbnail_id($recent['ID'])); if ($counters != 'none') { $recent['views'] = getPostViews($recent['ID']); $recent['comments'] = get_comments_number($recent['ID']); } $recent['post_protected'] = post_password_required($recent['ID']); $recent['post_content_prepared'] = do_shortcode($recent['post_content']); $recent['post_descr'] = $recent['post_format'] == 'quote' ? $recent['post_content_prepared'] : (!empty($recent['post_excerpt']) ? $recent['post_excerpt'] : getShortString(strip_tags(strip_shortcodes($recent['post_content'])), 300)); $recent['post_gallery'] = $recent['post_video'] = $recent['post_audio'] = ''; if ($recent['post_format'] == 'gallery') { $recent['post_gallery'] = buildGalleryTag(getPostGallery($recent['post_content'], $recent['ID']), 310, 310); } else { if ($recent['post_format'] == 'video') { $recent['post_video'] = getPostVideo($recent['post_content_prepared'], false); if ($recent['post_video'] == '') { $src = getVideoPlayerURL(getPostVideo($recent['post_content_prepared'], true), $recent['post_thumb'] != ''); if ($src) { $recent['post_video'] = substituteVideo('<video src="' . $src . '">', 310, 310);
</span> | In : <span class="post_cats"><?php the_category(', '); ?> </span> </h3> <h3> <span class="post_cats"><?php the_tags(); ?> </span> </h3> </div> <h4><?php //comments_number('0', '1', '%'); echo getPostViews(get_the_ID(), true); ?> </h4> </div> <div class="entry"> <?php //my_ad(); ?> <?php //the_content('',FALSE,''); the_excerpt(); ?> </div>
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); global $wp_query, $post; /* Our variables from the widget settings. */ $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $title_tabs = array(apply_filters('widget_title', isset($instance['title_popular']) ? $instance['title_popular'] : ''), apply_filters('widget_title', isset($instance['title_commented']) ? $instance['title_commented'] : '')); $number = isset($instance['number']) ? (int) $instance['number'] : ''; $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0; $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0; $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0; $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0; $category = isset($instance['category']) ? (int) $instance['category'] : 0; $output = $tabs = ''; for ($i = 0; $i < 2; $i++) { $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'order' => 'DESC'); if ($i == 0) { // Most popular $args['meta_key'] = 'post_views_count'; $args['orderby'] = 'meta_value_num'; } else { // Most commented $args['orderby'] = 'comment_count'; } if ($category > 0) { $args['cat'] = $category; } $ex = get_theme_option('exclude_cats'); if (!empty($ex)) { $args['category__not_in'] = explode(',', $ex); } query_posts($args); /* Loop posts */ if (have_posts()) { $tabs .= '<li><a href="#widget_popular_' . $i . '" class="theme_button"><span>' . $title_tabs[$i] . '</span></a></li>'; $output .= ' <div class="tab_content" id="widget_popular_' . $i . '"> '; $post_number = 0; while (have_posts()) { the_post(); $post_number++; $post_id = get_the_ID(); $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s')); $post_title = $post->post_title; $post_link = get_permalink(); $output .= ' <div class="post_item' . ($post_number == 1 ? ' first' : '') . '"> '; if ($show_image) { $post_thumb = getResizedImageTag($post_id, 60, 60); if ($post_thumb) { $output .= ' <div class="post_thumb image_wrapper">' . $post_thumb . '</div> '; } } $output .= ' <div class="post_wrapper"> <h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5> '; if ($show_date || $show_counters || $show_author) { $output .= ' <div class="post_info theme_info"> '; if ($show_date) { $output .= ' <span class="post_date theme_text">' . $post_date . '</span> '; } if ($show_author) { $post_author_id = $post->post_author; $post_author_name = get_the_author_meta('display_name', $post_author_id); $post_author_url = get_author_posts_url($post_author_id, ''); $output .= ' <span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span> '; } if ($show_counters) { if ($i == 0) { $post_counters = getPostViews($post_id); $post_comments_link = $post_link; } else { $post_counters = get_comments_number(); $post_comments_link = get_comments_link($post_id); } if ($show_counters == 2 && ($show_date || $show_author)) { $output .= '<br />'; } $output .= ' <span class="post_comments' . ($show_counters == 2 ? '_text' : '') . '"><a href="' . $post_comments_link . '">' . ($show_counters == 2 ? '' : '<span class="comments_icon icon-' . ($i == 0 ? 'eye' : 'chat-1') . '"></span>') . '<span class="post_comments_number">' . $post_counters . '</span>' . ($show_counters == 2 ? ' ' . ($i == 0 ? __('views', 'themerex') : __('comments', 'themerex')) : '') . '</a></span> '; } $output .= ' </div> '; } $output .= ' </div> </div> '; if ($post_number >= $number) { break; } } $output .= ' </div> '; } } /* Restore main wp_query and current post data in the global var $post */ wp_reset_query(); wp_reset_postdata(); if (!empty($output)) { wp_enqueue_script('jquery-ui-tabs', false, array('jquery', 'jquery-ui-core'), null, true); /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } echo ' <div class="popular_and_commented_tabs' . ($show_image ? '' : ' ordered_list') . ($show_image || $show_date || $show_counters > 1 || $show_author ? '' : ' flat_list') . '"> <ul class="tabs"> ' . $tabs . ' </ul> ' . $output . ' <script type="text/javascript"> jQuery(document).ready(function() { jQuery(\'.popular_and_commented_tabs\').tabs(); }); </script> </div> '; /* After widget (defined by themes). */ echo $after_widget; } }
function mom_category_content($cols = 2) { $cols = 'grid-col-' . $cols; $cat_data = get_option("category_" . get_query_var('cat')); $cat_layout = isset($cat_data['layout']) ? $cat_data['layout'] : ''; $cat_layout_style = isset($cat_data['layout_style']) ? $cat_data['layout_style'] : ''; $dateformat = mom_option('date_format'); $ad_id = mom_option('cat_ad_id'); $ad_count = mom_option('cat_ad_count'); $ad_repeat = mom_option('cat_ad_repeat'); $post_head = ''; $post_meta_hp = mom_option('post_meta_hp'); if ($post_meta_hp == 1) { $post_head = mom_option('post_head'); $post_head_author = mom_option('post_head_author'); $post_head_date = mom_option('post_head_date'); $post_head_cat = mom_option('post_head_cat'); $post_head_commetns = mom_option('post_head_commetns'); $post_head_views = mom_option('post_head_views'); } else { $post_head = 1; $post_head_author = 1; $post_head_date = 1; $post_head_cat = 1; $post_head_commetns = 1; $post_head_views = 1; } if (mom_option('cat_posts_layout') == 'blog' || $cat_layout == 'blog') { $style = ''; if (mom_option('cat_posts_layout_style') == 'large' || $cat_layout_style == 'large') { $style = 'large'; } else { $style = ''; } $nexcerpt = ''; $class = ''; ?> <div class="blog_posts"> <?php $post_count = 1; if (have_posts()) { while (have_posts()) { the_post(); ?> <?php mom_blog_post($style, $nexcerpt, $class); if ($ad_id != '') { if ($ad_repeat == 1) { if ($post_count % $ad_count == 0) { echo do_shortcode('[ad id="' . $ad_id . '"]'); } } else { if ($post_count == $ad_count) { echo do_shortcode('[ad id="' . $ad_id . '"]'); } } } $post_count++; ?> <?php } } else { ?> <!-- Else in here --> <?php } ?> <?php mom_pagination(); ?> </div> <?php } else { ?> <div class="site-content page-wrap"> <?php if (mom_option('cat_swi')) { ?> <div class="f-tabbed-head"> <ul class="f-tabbed-sort cat-sort"> <li class="grid active"><a href="#"><span class="brankic-icon-grid"></span><?php _e(' Grid', 'framework'); ?> </a></li> <li class="list"><a href="#"><span class="brankic-icon-list2"></span><?php _e(' List', 'framework'); ?> </a></li> </ul> </div> <?php } ?> <?php $catswi = mom_option('cat_swi_def'); $swiclass = 'cat-grid ' . $cols; if ($catswi == 'list') { $swiclass = 'cat-list'; } $srclass = ''; if (mom_option('cat_swi') != true) { $srclass = ' no-head'; } ?> <div class="cat-body<?php echo $srclass; ?> "> <ul class="nb1 <?php echo $swiclass; ?> clearfix"> <?php $post_count = 1; if (have_posts()) { while (have_posts()) { the_post(); ?> <li <?php post_class(); ?> itemscope="" itemtype="http://schema.org/Article"> <h2 itemprop="name" class="cat-list-title"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php if ($post_head != 0) { ?> <div class="cat-list-meta entry-meta"> <?php if ($post_head_author != 0) { ?> <div class="author-link"> <?php _e('Posted by', 'framework'); ?> <a itemprop="author" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author"><?php echo get_the_author(); ?> </a> </div> <?php } ?> <?php if ($post_head_date != 0) { ?> <span>|</span><time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><?php _e('Date: ', 'framework'); the_time($dateformat); ?> </time> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> <span>|</span><a href="<?php the_permalink(); ?> "> <?php comments_number(__('0 comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> <?php if ($post_head_views != 0) { ?> <div class="post-views"> <span>|</span><?php echo getPostViews(get_the_ID()); ?> </div> <?php } ?> </div> <?php } ?> <?php if (mom_post_image() != false) { ?> <figure class="post-thumbnail"><a href="<?php the_permalink(); ?> "> <?php mom_post_image_full('nb1-thumb'); ?> <span class="post-format-icon"></span> </a></figure> <?php } ?> <h2 itemprop="name" class="cat-grid-title"><a itemprop="url" href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <div class="entry-content cat-grid-meta"> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } echo wp_html_excerpt(strip_shortcodes($excerpt), 105); ?> ... </p> </div> <?php if (mom_post_image() != false) { $mom_class = ' class="fix-right-content"'; } else { $mom_class = ''; } ?> <div<?php echo $mom_class; ?> > <div class="entry-content cat-list-meta"> <p> <?php global $post; $excerpt = $post->post_excerpt; if ($excerpt == '') { $excerpt = get_the_content(''); } echo wp_html_excerpt(strip_shortcodes($excerpt), 200); ?> ... </p> </div> <?php if ($post_head != 0) { ?> <div class="cat-grid-meta entry-meta"> <?php if ($post_head_date != 0) { ?> <time class="entry-date" datetime="<?php the_time('c'); ?> " itemprop="dateCreated"><?php the_time($dateformat); ?> </time> <?php } ?> <?php if ($post_head_author != 0) { ?> <div class="author-link"> |<?php _e(' by ', 'framework'); ?> <a itemprop="author" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> " rel="author"><?php echo get_the_author(); ?> </a> </div> <?php } ?> <?php if ($post_head_commetns != 0) { ?> <div class="comments-link"> |<a href="<?php the_permalink(); ?> "> <?php comments_number(__('0 comments', 'framework'), __('(1) Comment', 'framework'), __('(%) Comments', 'framework')); ?> </a> </div> <?php } ?> </div> <?php } ?> <?php if (is_rtl()) { ?> <a class="read-more" href="<?php the_permalink(); ?> "><?php _e('Read more', 'framework'); ?> <i class="fa-icon-angle-double-left"></i></a> <?php } else { ?> <a class="read-more" href="<?php the_permalink(); ?> "><?php _e('Read more', 'framework'); ?> <i class="fa-icon-angle-double-right"></i></a> <?php } ?> </div> </li> <?php if ($ad_id != '') { if ($ad_repeat == 1) { if ($post_count % $ad_count == 0) { echo '<li>'; echo do_shortcode('[ad id="' . $ad_id . '"]'); echo '</li>'; } } else { if ($post_count == $ad_count) { echo '<li>'; echo do_shortcode('[ad id="' . $ad_id . '"]'); echo '</li>'; } } } $post_count++; } } else { ?> <!-- Else in here --> <?php } ?> </ul> <?php mom_pagination(); ?> </div> </div> <?php } }
/** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); global $wp_query, $post; /* Our variables from the widget settings. */ $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : ''); $number = isset($instance['number']) ? (int) $instance['number'] : ''; $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0; $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0; $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0; $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0; $category = isset($instance['category']) ? (int) $instance['category'] : 0; $counters = get_theme_option("blog_counters"); $output = ''; $args = array('numberposts' => $number, 'offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'ignore_sticky_posts' => 1, 'suppress_filters' => true); if ($category > 0) { $args['category'] = $category; } $ex = get_theme_option('exclude_cats'); if (!empty($ex)) { $args['category__not_in'] = explode(',', $ex); } $recent_posts = wp_get_recent_posts($args); $post_number = 0; foreach ($recent_posts as $post) { $post_number++; $post_id = $post['ID']; $post_date = getDateOrDifference($post['post_date']); $post_title = $post['post_title']; $post_link = get_permalink($post_id); $output .= ' <div class="post_item' . ($post_number == 1 ? ' first' : '') . '"> '; if ($show_image) { $post_thumb = getResizedImageTag($post_id, 60, 60); if ($post_thumb) { $output .= ' <div class="post_thumb image_wrapper">' . $post_thumb . '</div> '; } } $output .= ' <div class="post_wrapper"> <h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5> '; if ($show_date || $show_counters == 2 || $show_author) { $output .= ' <div class="post_info theme_info"> '; if ($show_date) { $output .= ' <span class="post_date theme_text">' . $post_date . '</span> '; } if ($show_author) { $post_author_id = $post['post_author']; $post_author_name = get_the_author_meta('display_name', $post_author_id); $post_author_url = get_author_posts_url($post_author_id, ''); $output .= ' <span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span> '; } if ($show_counters) { $post_counters = $counters == 'comments' ? get_comments_number($post_id) : getPostViews($post_id); $post_counters_link = $counters == 'comments' ? get_comments_link($post_id) : $post_link; if ($show_counters == 2 && ($show_date || $show_author)) { $output .= '<br />'; } $output .= ' <span class="post_comments' . ($show_counters == 2 ? '_text' : '') . '"><a href="' . $post_counters_link . '">' . ($show_counters == 2 ? '' : '<span class="comments_icon icon-' . ($counters == 'views' ? 'eye' : 'chat-1') . '"></span>') . '<span class="post_comments_number">' . $post_counters . '</span>' . ($show_counters == 2 ? ' ' . ($counters == 'views' ? __('views', 'themerex') : __('comments', 'themerex')) : '') . '</a></span> '; } $output .= ' </div> '; } $output .= ' </div> </div> '; if ($post_number >= $number) { break; } } if (!empty($output)) { /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ echo $before_title . $title . $after_title; echo $output; /* After widget (defined by themes). */ echo $after_widget; } }
function news_by_cat($args, $content) { if (!is_null($args['cat_id'])) { if (!is_null($args['take_num'])) { query_posts('cat=' . $args['cat_id'] . '&showposts=' . $args['take_num']); } else { query_posts('cat=' . $args['cat_id']); } if (have_posts()) { echo "<div class='news_content'><div class='alert news-alert alert-primary'><h3 class='news_title'>" . $args['cat_title'] . "</h3></div>"; echo "<hr/>"; while (have_posts()) { the_post(); ?> <div class="news-item"> <h3 class="h3 entry-title"><a href="<?php the_permalink(); ?> "><span class="entry-title-text"><?php the_title(); ?> </span></a></h3> <div class="posted-on"><span class="posted-on-string"><?php printf(__('Ngày đăng: %1$s', 'cswd'), get_the_date() . " " . get_the_time() . " Lượt xem: " . getPostViews(get_the_ID())); ?> </span></div> </div> <?php } echo "</div>"; } } }
function posts_custom_column_views($column_name, $id) { if ($column_name === 'post_views') { echo getPostViews(get_the_ID()); } }
function greenwall_blog() { $args = array('order' => 'desc', 'category_name' => 'Blog'); $posts = new WP_Query($args); if ($posts->have_posts()) { while ($posts->have_posts()) { $posts->the_post(); $date = new DateTime($posts->post->post_date); $date = $date->format('Y/m/d'); $count = getPostViews($posts->post->ID); $author = get_the_author_meta('display_name', $posts->post->post_author); $author_posts = get_the_author_meta('user_url', $post_author); $string = '<div id="box" class="box">' . '<article>' . '<figure>' . '<img height="300" width="370" src="' . wp_get_attachment_url(get_post_thumbnail_id($posts->post->ID)) . '" alt="view hydroponics">' . '</figure>' . '<div class="article-content">' . '<head>' . '<h2>' . $posts->post->post_title . '</h2>' . '</head>' . '<footer>' . '<ul>' . '<li><i class="icon-user"></i><a href="' . $author_posts . '"><span>' . $author . '</span></a></li>' . '<li><i class="icon-calendar"></i><span>' . $date . '</span></li>' . '<li><i class="icon-bubbles4"></i><a href="#"><span>' . $posts->post->comment_count . '</span></a></li>' . '<li><i class="icon-eye"></i><span>' . $count . '</span></li>' . '</ul>' . '</footer>' . '<div>' . '<p>' . $posts->post->post_excerpt . '</p>' . '<div class="readmore"><a href="' . get_permalink($posts->post->_ID) . '">Read more</a></div>' . '</div>' . '</div>' . '</article>' . '</div>'; echo $string; } } wp_reset_postdata(); }
?> <span class="category"> <i class="icon-folder-close"></i> <?php echo '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a>'; ?> </span> <?php } ?> <span class="views"> <i class="icon-eye-open"></i> <?php echo getPostViews(get_the_ID()); ?> </span> </div> </header> <div class="entry-excerpt"> <?php the_excerpt(); ?> </div> </div><!-- /one-half --> <?php } ?>
function sc_blogger($atts, $content = null) { extract(shortcode_atts(array("id" => "", "style" => "regular", "bubble_color" => "", "ids" => "", "cat" => "", "count" => "3", "offset" => "", "orderby" => "date", "order" => "desc", "descr" => "0", "readmore" => "0", "dir" => "horizontal", "border" => "0", "rating" => "1", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts)); $s = ($top !== '' ? 'margin-top:' . $top . 'px;' : '') . ($bottom !== '' ? 'margin-bottom:' . $bottom . 'px;' : '') . ($left !== '' ? 'margin-left:' . $left . 'px;' : '') . ($right !== '' ? 'margin-right:' . $right . 'px;' : ''); global $THEMEREX_sc_blogger_counter, $post; $THEMEREX_sc_blogger_counter = 0; if (!in_array($style, array('regular', 'date', 'image_large', 'image_medium', 'image_small', 'bubble_left', 'bubble_top', 'accordion', 'puzzles', 'underline'))) { $style = 'regular'; } if (!empty($ids)) { $posts = explode(',', str_replace(' ', '', $ids)); $count = count($posts); } if ($style == 'accordion') { $dir = 'vertical'; } $output = $style == 'puzzles' ? '' : '<div' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_blogger' . ' sc_blogger_' . ($dir == 'vertical' ? 'vertical' : 'horizontal') . ' style_' . $style . ($style == 'accordion' ? ' sc_accordion' : '') . ($dir != 'vertical' && $style != 'puzzles' ? ' sc_columns sc_columns_count_' . $count : '') . '"' . ($s != '' ? ' style="' . $s . '"' : '') . '>'; $counters = get_theme_option("blog_counters"); $args = array('post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc', 'orderby' => 'date'); if ($offset > 0 && empty($ids)) { $args['offset'] = $offset; } $args = addSortOrderInQuery($args, $orderby, $order); $args = addPostsAndCatsInQuery($args, $ids, $cat); $query = new WP_Query($args); while ($query->have_posts()) { $query->the_post(); $post_id = get_the_ID(); $post_protected = post_password_required(); $post_format = get_post_format(); $post_link = get_permalink(); $post_comments_link = $counters == 'comments' ? get_comments_link($post_id) : $post_link; $post_comments = get_comments_number(); $post_views = getPostViews($post_id); $post_date = prepareDateForTranslation(get_the_date()); $post_date_sql = get_the_date('Y-m-d H:i:s'); $post_date_diff = getDateOrDifference($post_date_sql); $post_icon = getPostFormatIcon($post_format); $post_author = get_the_author(); $post_author_id = get_the_author_meta('ID'); $post_author_url = get_author_posts_url($post_author_id, ''); $post_title_tag = $dir == 'vertical' ? 'h3' : 'h4'; $post_thumb_w = $post_thumb_h = 0; if (themerex_strpos($style, 'bubble') !== false) { $post_custom_options = get_post_meta($post_id, 'post_custom_options', true); $post_icon = isset($post_custom_options['page_icon']) ? $post_custom_options['page_icon'] : $post_icon; $post_title_tag = 'h2'; } else { if ($style == 'image_small') { $post_thumb = getResizedImageTag($post_id, 120, 80); } else { if ($style == 'image_medium') { $post_thumb = getResizedImageTag($post_id, $post_thumb_w = 279, $post_thumb_h = 186); } else { if ($style == 'image_large') { $post_thumb = getResizedImageTag($post_id, $post_thumb_w = 466, $post_thumb_h = 310); } else { if ($style == 'puzzles') { $post_thumb = getResizedImageTag($post_id, $post_thumb_w = 310, $post_thumb_h = 310); } } } } } //$post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id)); if (get_theme_option('preserve_decoration') == 'no') { // -------------- Old way to get title, excerpt and content ----------------------- $post_title = get_the_title(); $post_content_full = $post->post_content; //get_the_content() not used, because it trim content up to <!-- more --> in each case! $post_content_prepared = strip_shortcodes($post_content_full); //do_shortcode($post_content_full); //do_shortcode() make a recursion if insert shortcode [blogger] in the posts!!!! $post_excerpt = in_array($post_format, array('quote', 'link')) && $style == 'puzzles' ? $post_content_prepared : ($descr > 0 ? strip_tags(strip_shortcodes(getPostDescription($descr, $readmore ? '' : '...'))) : ''); } else { // ----------------- New way to get title, excerpt and content ----------------------- $post_title = $post_title_plain = get_the_title(); global $more; $old_more = $more; $more = -1; $post_content_full = get_the_content(); $post_content_prepared = do_shortcode($post_content_full); $more = $old_more; $post_content = get_the_content(null); $post_excerpt = has_excerpt() || $post_protected ? get_the_excerpt() : ''; if (empty($post_excerpt)) { if (($more_pos = themerex_strpos($post_content_full, '<span id="more-')) !== false) { $post_excerpt = themerex_substr($post_content_full, 0, $more_pos); } else { $post_excerpt = in_array($post_format, array('quote', 'link')) ? $post_content : get_the_excerpt(); } } $post_excerpt = str_replace('[…]', '', $post_excerpt); if (!in_array($post_format, array('quote', 'link')) && $descr > 0 && themerex_strlen($post_excerpt) > $descr) { $post_excerpt = getShortString(strip_tags(do_shortcode($post_excerpt)), $descr, $readmore ? '' : '...'); } $post_excerpt .= !in_array($post_format, array('quote', 'link')) && $readmore ? ' <a href="' . $post_link . '" class="readmore">' . ($readmore == 1 ? '»' : $readmore) . '</a>' : ''; //$post_content = apply_filters('the_content', $post_content); // ------------------ /New way to get title, excerpt and content ----------------------- } $post_excerpt = apply_filters(in_array($post_format, array('quote', 'link')) ? 'the_content' : 'the_excerpt', force_balance_tags($post_excerpt)); // Extract gallery, video and audio from full post content $post_gallery = $post_video = $post_audio = $post_url = $post_url_target = ''; if (in_array($style, array('image_medium', 'image_large', 'puzzles'))) { if ($post_format == 'gallery') { $post_gallery = buildGalleryTag(getPostGallery($post_content_full, $post_id), $post_thumb_w, $post_thumb_h); } else { if ($post_format == 'video') { $post_video = getPostVideo($post_content_full, false); if ($post_video == '') { $src = getVideoPlayerURL(getPostVideo($post_content_full, true), $post_thumb != ''); if ($src) { $post_video = substituteVideo('<video src="' . $src . '">', $post_thumb_w, $post_thumb_h); } } if ($post_video != '' && get_custom_option('substitute_video') == 'yes') { $src = getVideoPlayerURL(getPostVideo($post_video), $post_thumb != ''); if ($src) { $post_video = substituteVideo('<video src="' . $src . '">', $post_thumb_w, $post_thumb_h); } } } else { if ($post_format == 'audio') { $post_audio = getPostAudio($post_content_full, false); if ($post_audio == '') { $src = getPostAudio($post_content_full, true); if ($src) { $post_audio = substituteAudio('<audio src="' . $src . '">'); } } if ($post_audio != '' && get_custom_option('substitute_audio') == 'yes') { $src = getPostAudio($post_audio); if ($src) { $post_audio = substituteAudio('<audio src="' . $src . '">'); } } } else { if ($post_format == 'image' && !$post_thumb) { if (($src = getPostImage($post_content_full)) != '') { $post_thumb = getResizedImageTag($src, $post_thumb_w, $post_thumb_h); } } else { if ($post_format == 'link') { $post_url_data = getPostLink($post_content_full, false); $post_url = $post_url_data['url']; $post_url_target = $post_url_data['target']; } } } } } } // Get all post's categories $post_categories = getCategoriesByPostId($post_id); $post_categories_str = ''; $post_accent_color = ''; $post_accent_category = ''; $ex_cats = explode(',', get_theme_option('exclude_cats')); for ($i = 0; $i < count($post_categories); $i++) { if (in_array($post_categories[$i]['term_id'], $ex_cats)) { continue; } if ($post_accent_category == '') { if (get_theme_option('close_category') == 'parental') { $parent_cat_id = 0; //(int) get_custom_option('category_id'); $parent_cat = getParentCategory($post_categories[$i]['term_id'], $parent_cat_id); if ($parent_cat) { $post_accent_category = $parent_cat['name']; if ($post_accent_color == '') { $post_accent_color = getCategoryInheritedProperty($parent_cat['term_id'], 'theme_accent_color'); } } } else { $post_accent_category = $post_categories[$i]['name']; if ($post_accent_color == '') { $post_accent_color = getCategoryInheritedProperty($post_categories[$i]['term_id'], 'theme_accent_color'); } } } $post_categories_str .= '<a class="cat_link" href="' . $post_categories[$i]['link'] . '">' . $post_categories[$i]['name'] . ($i < count($post_categories) - 1 ? ',' : '') . '</a> '; } if ($post_accent_category == '' && count($post_categories) > 0) { $post_accent_category = $post_categories[0]['name']; if ($post_accent_color == '') { $post_accent_color = getCategoryInheritedProperty($post_categories[0]['term_id'], 'theme_accent_color'); } } if ($style == 'puzzles') { $post_hover_bg = get_custom_option('puzzles_post_bg', null, $post_id); $post_hover_pos = get_custom_option('puzzles_post_position', null, $post_id); } // Prepare reviews block $reviewsBlock = ''; $avg_author = 0; if ($rating > 0 && get_custom_option('show_reviews', null, $post_id) == 'yes') { $avg_author = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . (get_theme_option('reviews_first') == 'author' ? '' : '2'), true)); if ($avg_author > 0) { $reviewsBlock .= '<div class="reviews_summary blog_reviews' . ($style == 'puzzles' ? ' theme_puzzles' : '') . '"' . ($style == 'puzzles' && $post_hover_bg != '' && $post_hover_bg != 'default' ? ' style="background-color:' . $post_hover_bg . ';"' : '') . '>' . '<div class="criteria_summary criteria_row">' . getReviewsSummaryStars($avg_author) . '</div>' . '</div>'; } } // Start output $THEMEREX_sc_blogger_counter++; $output .= '<div class="sc_blogger_item' . ($style == 'puzzles' ? ' sc_blogger_item_puzzles' : '') . ($style == 'date' ? ' sc_blogger_item_date' : '') . ($style == 'accordion' ? ' sc_accordion_item' : '') . ($dir != 'vertical' && $style != 'puzzles' ? ' sc_column_item sc_column_item_' . $THEMEREX_sc_blogger_counter : '') . ($border == 1 ? ' sc_blogger_item_bordered' : '') . ($THEMEREX_sc_blogger_counter % 2 == 1 ? ' odd' : ' even') . ($THEMEREX_sc_blogger_counter == 1 ? ' first' : '') . '"> '; if ($style == 'puzzles') { $show_content_block = !in_array($post_format, array('link', 'image')) || !$post_thumb; $puzzles_style = get_custom_option('puzzles_style'); $no_thumb = in_array($post_format, array('quote', 'link', 'image')) || !$post_thumb && (!$post_gallery || $post_protected); $output .= '<div class="post_thumb image_wrapper post_format_' . $post_format . ' ' . ($no_thumb ? 'no_thumb' : $post_hover_pos) . '"' . ($post_video && !$post_protected ? ' data-video="' . htmlspecialchars($post_video) . '"' : '') . '>'; if ($post_thumb && ($post_format != 'gallery' || !$post_gallery || get_custom_option('gallery_instead_image') == 'no')) { // If post have thumbnail - show it if ($post_format == 'link' && $post_url != '') { $output .= '<a href="' . $post_url . '"' . ($post_url_target ? ' target="' . $post_url_target . '"' : '') . '>' . $post_thumb . '</a>'; } else { if ($post_link != '') { $output .= '<a href="' . $post_link . '">' . $post_thumb . '</a>'; } else { $output .= $post_thumb; } } if ($post_format == 'video' && $post_video && !$post_protected) { $output .= '<a href="#" class="post_video_play icon-play"></a>'; } } else { if ($post_gallery && !$post_protected) { // If post have gallery - show it if ($post_link != '') { $output .= '<a href="' . $post_link . '">' . $post_gallery . '</a>'; } else { $output .= $post_gallery; } } else { if ($post_video && !$post_protected) { // If post have video - show it $output .= $post_video; $show_content_block = false; } } } $output .= '<span class="post_format theme_accent_bg ' . $post_icon . '"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '></span>'; if ($puzzles_style == 'heavy') { if ($post_accent_category != '') { $output .= '<span class="post_category theme_accent_bg"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '>' . $post_accent_category . '</span>'; } } else { if ($show_content_block) { $output .= '<div class="post_content_light">' . ($post_accent_category != '' ? '<span class="post_category theme_accent_bg"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '>' . $post_accent_category . '</span><br>' : '') . '<h2 class="post_subtitle theme_puzzles"' . ($post_hover_bg != '' && $post_hover_bg != 'default' ? ' style="background-color:' . $post_hover_bg . ';"' : '') . '><a href="' . $post_link . '">' . $post_title . '</a></h2><br>' . $reviewsBlock . '</div>'; } } if ($show_content_block) { $output .= '<div class="post_content_wrapper theme_puzzles"' . ($post_hover_bg != '' && $post_hover_bg != 'default' ? ' style="background-color:' . $post_hover_bg . ';"' : '') . '>'; if (!in_array($post_format, array('quote', 'aside'))) { $output .= '<h2 class="post_subtitle"><a href="' . $post_link . '">' . $post_title . '</a></h2>'; $output .= $reviewsBlock; } $output .= '<div class="post_descr">' . $post_excerpt . '</div>' . '<div class="post_content_padding theme_puzzles"'; if ($post_hover_bg != '' && $post_hover_bg != 'default') { $rgb = Hex2RGB($post_hover_bg); $post_hover_ie = str_replace('#', '', $post_hover_bg); $output .= " style=\"\n\t\t\t\t\t\tbackground: -moz-linear-gradient(top, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tbackground: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0)), color-stop(1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01)), color-stop(50%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1)));\n\t\t\t\t\t\tbackground: -webkit-linear-gradient(top, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tbackground: -o-linear-gradient(top, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tbackground: -ms-linear-gradient(top, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tbackground: linear-gradient(to bottom, rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0) 0%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.01) 1%,rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},1) 50%);\n\t\t\t\t\t\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00{$post_hover_ie}', endColorstr='#{$post_hover_ie}',GradientType=0 );\n\t\t\t\t\t\t\""; } $output .= '></div></div>'; } if (!$post_protected) { if ($post_audio) { // If post have audio - show it $output .= $post_audio; } } $output .= '</div>'; } else { $title = '<' . $post_title_tag . ' class="sc_blogger_title sc_title entry-title' . ($style == 'accordion' ? ' sc_accordion_title' : '') . ($style == 'underline' ? ' sc_title_underline' : '') . (themerex_strpos($style, 'bubble') !== false ? ' sc_title_bubble sc_title_' . $style : '') . '">' . '<a href="' . ($style == 'accordion' ? '#' : $post_link) . '">' . (themerex_substr($style, 0, 6) == 'bubble' ? '<span class="sc_title_bubble_icon ' . ($post_icon != '' ? ' ' . $post_icon : '') . '"' . ($bubble_color != '' ? ' style="background-color:' . $bubble_color . '"' : '') . '></span>' : '') . ($style == 'accordion' ? '<span class="sc_accordion_icon"></span>' : '') . $post_title . ($style == 'accordion' ? '' : $reviewsBlock) . '</a>' . '</' . $post_title_tag . '>'; if ($style == 'date') { $output .= '<div class="date_area">' . '<div class="date_month">' . prepareDateForTranslation(date('M', strtotime($post_date_sql))) . '</div>' . '<div class="date_day">' . date('d', strtotime($post_date)) . '</div>' . '</div>'; } else { if (themerex_strpos($style, 'image') !== false) { $output .= ($style == 'image_small' ? '<div class="title_area">' . $title . '</div>' : ($post_thumb ? '<div class="sc_blogger_image image_wrapper">' . ($post_link != '' ? '<a href="' . $post_link . '">' : '') . $post_thumb . ($post_link != '' ? '</a>' : '') . '</div>' : '')) . '<div class="post_wrapper">' . '<div class="post_info theme_info">' . __('Posted', 'themerex') . ' <span class="post_date theme_text">' . $post_date_diff . '</span> ' . '<span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '" class="post_author">' . $post_author . '</a></span>' . '<br />' . ($post_categories_str != '' ? '<span class="post_cats">' . __('in', 'themerex') . ' ' . $post_categories_str . '</span>' : '') . ($counters == 'none' ? '' : '<span class="post_comments"><a href="' . $post_comments_link . '"><span class="comments_icon theme_info icon-' . ($orderby == 'comments' || $counters == 'comments' ? 'chat-1' : 'eye') . '"></span><span class="comments_number">' . ($orderby == 'comments' || $counters == 'comments' ? $post_comments : $post_views) . '</span></a></span>') . '</div>' . ($style == 'image_small' ? '' : '<div class="title_area">'); } } $output .= $style == 'image_small' ? '' : $title; if (themerex_strpos($style, 'image') !== false) { $output .= $style == 'image_small' ? $post_thumb ? '<div class="sc_blogger_image image_wrapper">' . ($post_link != '' ? '<a href="' . $post_link . '">' : '') . $post_thumb . ($post_link != '' ? '</a>' : '') . '</div>' : '' : '</div>'; } if ($descr > 0) { $output .= '<div class="sc_blogger_content' . ($style == 'accordion' ? ' sc_accordion_content' : '') . '">' . $post_excerpt . '</div>'; } if (themerex_strpos($style, 'image') !== false) { $output .= '</div>'; } } $output .= '</div>'; } wp_reset_postdata(); if ($style !== 'puzzles') { $output .= '</div>'; } if ($style == 'accordion') { wp_enqueue_script('jquery-ui-accordion', false, array('jquery', 'jquery-ui-core'), null, true); $output .= '<script type="text/javascript"> jQuery(document).ready(function() { jQuery(\'div' . ($id ? '#' . $id : '') . '.sc_blogger.sc_accordion\').accordion({ header: "h3", collapsible: true, heightStyle: "content" }); }); </script>'; } if ($border == 1) { $output .= '<script type="text/javascript"> jQuery(document).ready(function() { var maxHeight = 0; for (var i=0; i<2; i++) { jQuery(\'.sc_blogger_item_bordered\').each(function(){ if (i > 0) { if (maxHeight>0) jQuery(this).height(maxHeight); } else if (jQuery(this).height() > maxHeight) maxHeight = jQuery(this).height(); }); } }); </script>'; } return $output; }