Showing posts in wordpress widget

To show number of posts from a particular category, use the following code: <?php query_posts('cat=11&post_status=publish&posts_per_page=5,future'); if ( have_posts() ) : while ( have_posts() ) : //the_post(); echo '<div><a href="'.the_permalink().'">'.the_title().'</a></div>'; endwhile; endif; ?>

Keyboard shortcuts for browsing pages of lists

If you want to add keyboard shortcut (right and left arrow keys) to navigate between a list of pages then use javascript code below. // Keyboard shortcuts for browsing pages of lists $(document).keydown(handleKey); function handleKey(e){ var left_arrow = 37; var right_arrow = 39; if (e.target.localName == 'body' || e.target.localName == 'html'){ if (!e.ctrlKey && !e.altKey … Continue reading Keyboard shortcuts for browsing pages of lists

Importing Gmail Contacts Using CURL and PHP

The code to import your Gmail address book using PHP and curl is here. If you want to import the contacts to our site from Gmail. Please try given script: <?php $location = ""; $cookiearr = array(); $csv_source_encoding='utf-8'; #function get_contacts, accepts as arguments $login (the username) and $password #returns array of: array of the names … Continue reading Importing Gmail Contacts Using CURL and PHP

Update currency rates for your ecommerce website

public function updateExchangeRate(){ // Fetch currency rate if (time()-filemtime("eurofxref-daily.xml") > 36000) { $stuff = file("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"); $fh = fopen("eurofxref-daily.xml","w"); foreach ($stuff as $line) { fputs($fh,$line); } fclose ($fh); $xld = "loaded afresh (and not cached)"; } else { # .. or read from cache $stuff = file("eurofxref-daily.xml"); $xld = "cached (and not loaded afresh)"; } # … Continue reading Update currency rates for your ecommerce website