How To: Avoid Duplicate Posts


The Codex article the reader mentioned was regarding the Loop. Although the example shows how to avoid a single duplicate post, it doesn’t show how to avoid duplicating multiple posts.

Here’s how to show two individual loops without duplicating posts in either loop.

Step 1: Add a ‘posts_where’ Function

WordPress filter is needed to accomplish this, and we’re going to be tapping into the ‘posts_where‘ filter.

The reason being is we need to modify the query used for the loop and exclude some posts.

Here’s the function we’ll be using called post_strip:

 

function post_strip($where) {
	global $myPosts, $wpdb;
	$where .= " AND $wpdb->posts.ID not in($myPosts) "; 
	return $where;
}

 

In the above code, I use a global variable called $myPosts, which is comma-separated string of post IDs to exclude.

Step 2: Start the First Loop

Within this first loop we’ll be keeping track of the post IDs being used. Nothing fancy is being done here. We’re just pulling the last five posts posted.

 

<?php 
global $myPosts;
$myPosts = '';
?>
<div>
<?php
$my_query = new WP_Query();
$my_query->query('showposts=5');
if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php $myPosts .= $post->ID . ","; ?>
<div><?php the_title(); ?></div>
<!-- Post Stuff -->
<?php endwhile; endif; ?>
</div>

 

Pay special attention to the $myPosts variable, which is used to keep track of all of the post IDs.

Step 3: Add the Filter

We’ll now need to add a posts_where filter for the second loop. This filter will use thepost_strip function we started in Step 1.

 

<?php add_filter('posts_where', 'post_strip'); ?>

 

Step 4: Start the Second Loop

The second loop is a repeat of the first loop to demonstrate that the posts are not being duplicated. The second loop uses a different loop technique since paging isn’t necessary.

 

<div>
<?php
$my_query = new WP_Query('showposts=5');
while ($my_query->have_posts()) : $my_query->the_post();?> 
<div><?php the_title(); ?></div>

<!-- Post Stuff -->

<?php endwhile; ?>
</div>

 

Step 5: Remove the Filter

The filter we added in Step 3 now needs to be removed.

 

<?php remove_filter('posts_where', 'post_strip'); ?>

 

Step 6: Admire the Results

Before Duplicates Being Shown
Before – Duplicates Being Shown

After - Duplicates Removed
After – Duplicates Removed

Downloadable Code

Here is a sample index.php for download.

 

Ref : http://weblogtoolscollection.com/archives/2008/05/17/how-to-avoid-duplicate-posts/

Google Picks 12 Top Android Apps of 2012


Google has released its list of the top Android apps of 2012. This year’s list includes not only apps that were released this year, such as Pinterest’s Android app, but also apps that saw significant updates during the past calendar year.

Ranging from an app to help you monitor your finances to an app to help you book your next vacation, the chosen apps all sport a clean and easy-to-use design, representing what Google feels are the best of the best in Google Play.

Almost all of the apps on the list are also available for phones and tablets, so whether you have a Galaxy S III smartphone, or a Nexus 7 tablet, you can likely take advantage of everything they have to offer.

Check out the full list of apps in the gallery above. Did your favorite Android app make the list? Tell us what Google missed in the comments.

Thumbnail image Mashable

Source : http://mashable.com/2012/12/27/12-best-android-apps-of-2012/

Google Calendar – WordPress


Google Calendar is a free calendar application from Google that makes it easy to keep track of life’s important events all in one place.

Embedding a Google Calendar

  • You can embed a Google calendar into your WordPress.com blog by using the Google calendar embed code. To generate your embed code, please follow these steps.

    Click on the little arrow next to your calendar name and select the Calendar settings link.

  • Click the Share this Calendar tab and make your calendar public by checking the checkboxes next to Share this calendar with others & Make this calendar public. Don’t forget to press the Savebutton when you are done.
  • Click on the Calendar Details tab and copy/paste the embed code into your blog. The embed code contains your Google account name, so be sure you’re okay with making that name public.
  • In your WordPress.com dashboard, go to Posts -> Add New or Pages -> Add New (or open an existing post/page in editing mode). Paste the code directly into your Text editor. (You can switch between the Visual and Text editors using the tab at the top-right of the editing box.)
  • Click Save Draft, Update, or Publish depending on the status of your post or page. You will notice that the code has changed. WordPress has converted the HTML code into the working shortcode.
  • Here is an example of what an embedded calendar will look like.
  • Embedding a Google Calendar into your Sidebar

    Follow steps 1-5 above and copy the shortcode from step 5.
    Go to your Widgets page (Appearance -> Widgets from your blog’s Dashboard).
    Add a Text Widget to your sidebar.
    Add a title to your widget (if you want one).
    Paste the shortcode into the text widget.
    Press the Save button and go to your blog and admire your awesome new calendar.

  • Additional Info
  • When adding Google Calendars to your WordPress.com blog, do NOT manually open the shortcode as you normally do with other services (i.e. do not begin typing the shortcode and then paste the calendar code). This will not work.
  • To customize your calendar, click the Customize the color, size, and other options link during step 3 above.
  • Source :http://en.support.wordpress.com/google-calendar/#toc

    Keep Your Upgrades in Order


    As more and more of you take advantage of our fabulous Upgrades, we’ve been conscious of the increasing need to offer a great way to manage your purchases. What if you could track all of your upgrades, manage them, renew them and *gasp* even cancel them, all in one place?

    Well, starting today you’ll see a new page in the Store section of your dashboard: My Upgrades.

    On that page you’ll find the list of the upgrades purchased for the site you are managing, followed by a lists of the upgrades you have on your other sites, if any.

    Domain registration, mapping, Custom Design, Space upgrade, VideoPress or Premium theme, you will find them all here, along with links allowing you to renew, enable auto renew, update credit card data, or cancel ( and get a refund within the appropriate timeframe ).

     

    As you can see, the status of each upgrade and its expiration date are clearly displayed there, with some handy color-coding:

    • One-time purchases (Premium theme in the screenshot above) or upgrades currently set to auto-renew (Domain) are displayed in green
    • Upgrades which need to be renewed manually are displayed in orange ( 10GB Space, Custom Design )
    • When these upgrades which need to be renewed manually get close to their expiration date, they are displayed in red ( VideoPress )

    You’ll also find some handy dandy links to more information about each upgrade, just in case you forget why you bought it! When appropriate, we give you links to the settings page, too.

    We’ve got plenty of exciting updates planned, including the ability to visualize, save, and print your own billing reports and purchase receipts – so keep an eye on the page for more!

    Never forget a renewal anymore, visit the My Upgrades section of the

    Source :http://en.blog.wordpress.com/2012/03/26/keep-your-upgrades-in-order/

    dashboard.