function get_popular_ajax() { $page = $_GET["page"]; $postPerPage = $_GET["posts_per_page"] == "" ? 4 : $_GET["posts_per_page"]; //wp_reset_query(); $args = array('post_type' => 'blog', 'paged' => $page, 'offset' => ($page - 1) * $postPerPage + 1, 'posts_per_page' => $postPerPage, 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC'); //$arrPost = query_posts($args); $postQuery = new WP_Query($args); $arrPost = $postQuery->get_posts(); if ($arrPost != NULL) { foreach ($arrPost as $post) { $postId = $post->ID; /*Bugfix: show correct thumbnail for posts*/ $thumbId = get_post_thumbnail_id($postId); $iurl = wp_get_attachment_url($thumbId); //if empty, show default thumbnail if (empty($iurl)) { $iurl = get_bloginfo('stylesheet_directory') . "/i/content-thumb.png"; } ?> <li> <!-- Bug# I-104876 href comes as empty on "show more" --> <a class="contentLink" href="<?php echo get_permalink($postId); ?> "> <img class="contentThumb" src="<?php echo $iurl; ?> " alt="<?php echo $post->post_title; ?> "> <?php echo $post->post_title; ?> </a> <span class="contentBrief"><?php echo wrap_content_strip_html(wpautop($post->post_content), 70, TRUE, '\\n\\r', '...'); ?> </span> </li> <?php } } die; /* $arrPost = query_posts($args); if ($arrPost != NULL) : foreach ($arrPost as $post) : $postId = $post->ID; ?> <li> <!-- Bug# I-104876 href comes as empty on "show more" - --> <!-- Bug# I-104876 fix href to use rel urls - --> <a class="contentLink" href="<?php echo get_rel_url(get_permalink($postId), TRUE); ?>"> <img class="contentThumb" src="<?php bloginfo('stylesheet_directory'); ?>/i/content-thumb.png" alt="<?php echo $post->post_title; ?>"> <?php echo $post->post_title; ?> </a> <span class="contentBrief"><?php echo wrap_content_strip_html( wpautop($post->post_content), 70, TRUE, '\n\r', '...' ); ?></span> </li> <?php endforeach; endif; die(); */ }
<div class="imagePlaceholder"> <a href="<?php the_permalink(); ?> "><img src="<?php echo $imageUrl; ?> " width="158" height="158" alt=""></img></a> </div> <!-- Imageplacehoder End --> <!-- Content Right --> <div class="contentRight"> <div class="excerpt"> <?php $excerpt = wrap_content_strip_html(wpautop($post->post_content), 400, true, '\\n\\r', ''); echo $excerpt; ?> </div> <div class="shareVia"> <span>Share via : </span> <a href="<?php echo $email_article; ?> " class="shareButton shareMail small"></a> <a href="<?php echo $fbShare; ?> " class="shareButton shareFb small"></a> <a href="<?php echo $twitterShare;
function createTwitterPost($text, $permalink) { return "//twitter.com/home?status=Blog:%20" . str_replace('%0A', '', urlencode(wrap_content_strip_html(wpautop($text), 100, true, '\\n\\r')) . " " . $permalink . " via @topcoder"); }
$qAuthor = get_post_meta($post->ID, "Quote author", true); $image = wp_get_attachment_image_src(get_post_thumbnail_id($postId), 'single-post-thumbnail'); if ($image != null) { $imageUrl = $image[0]; } else { $imageUrl = get_bloginfo('stylesheet_directory') . "/i/story-side-pic.png"; } $dateObj = DateTime::createFromFormat('Y-m-d H:i:s', $post->post_date); $dateStr = $dateObj->format('M j, Y'); $title = htmlspecialchars($post->post_title); $subject = htmlspecialchars(get_bloginfo('name')) . ' : ' . $title; $body = htmlspecialchars($post->post_content); $email_article = 'mailto:?subject=' . rawurlencode($subject) . '&body=' . get_permalink($postId); //Bugfix I-109975: Correct format of twitter blog post shares $twitterShare = createTwitterPost($title, get_permalink($postId)); $fbShare = "http://www.facebook.com/sharer/sharer.php?s=100&p[url]=" . get_permalink($postId) . "&p[images][0]=" . $imageUrl . "&p[title]=" . get_the_title() . "&p[summary]=" . urlencode(wrap_content_strip_html(wpautop($title), 130, true, '\\n\\r', '')); $gplusShare = "https://plus.google.com/share?url=" . get_permalink($postId); $authorObj = get_user_by("id", $post->post_author); $authorLink = get_bloginfo("wpurl") . "/author/" . $authorObj->user_nicename; $categories = get_the_category(); $arrCategoriesId; if ($categories != null) { foreach ($categories as $key => $category) { $arrCategoriesId[] = $category->term_id; } } ?> <!-- Start Overview Page--> <!-- page title --> <div class="pageTitleWrapper">
/** * How to display the widget on the screen. */ function widget($args, $instance) { // Widget output extract($args); /* Our variables from the widget settings. */ $title = $instance['title']; $postPerPage = $instance['post_per_page']; /* Before widget (defined by themes). */ echo $before_widget; //wp_reset_query(); $title = $title == "" ? "Popular Posts" : $title; $postPerPage = $postPerPage == "" ? 4 : $postPerPage; $args = array('post_type' => 'blog', 'posts_per_page' => $postPerPage, 'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC'); //query_posts($args); $postQuery = new WP_Query($args); if ($postQuery->have_posts()) { ?> <div class="sideFindRelatedContent sideFindRelatedContentNoBorder"> <input class="popularPostPage" type="hidden" value="<?php echo $postPerPage; ?> "/> <input type="hidden" class="pageNo" value="1"/> <h3 class="popularPostTitle"><?php echo $title; ?> </h3> <ul class="relatedContentList"> <?php while ($postQuery->have_posts()) { $postQuery->the_post(); // advance to next record and set global $post var $post; /*Bugfix: show correct thumbnail for posts*/ $postId = get_the_ID(); $thumbId = get_post_thumbnail_id($postId); $iurl = wp_get_attachment_url($thumbId); //if empty, show default thumbnail if (empty($iurl)) { $iurl = get_bloginfo('stylesheet_directory') . "/i/content-thumb.png"; } ?> <li> <a class="contentLink" href="<?php the_permalink(); ?> "> <img class="contentThumb" src="<?php echo $iurl; ?> " alt="<?php the_title(); ?> "> <?php the_title(); ?> </a> <span class="contentBrief"><?php echo wrap_content_strip_html(wpautop(get_the_content()), 70, TRUE, '\\n\\r', '...'); ?> </span> </li> <?php } ?> </ul> </div> <!-- /.popular post--> <?php } wp_reset_postdata(); ?> <?php /* After widget (defined by themes). */ echo $after_widget; }
for ($j = $i * 5; $j < $i * 5 + 5 && $j < $nr_of_forum_posts; $j++) { ?> <div class="post postDesign"> <a href="#" class="thumb"></a> <div class="head"> <a href="<?php echo $forum_items[$j]->link; ?> " class="postTitle"><?php echo $forum_items[$j]->title; ?> </a> <span class="postedBy">Last Post by: <a href="#" class="postAuthor">Mahestro</a></span> </div> <div class="postBody"><?php echo wrap_content_strip_html($forum_items[$j]->description, 120, true, '\\n\\r', ''); ?> </div> <div class="postInfo"> <div class="row"> <a href="#" class="postCat"><?php echo $forum_items[$j]->category; ?> </a> <span class="sep"></span><span class="postedAt"><?php echo $forum_items[$j]->pubDate; ?> </span> </div> <div class="row">