Richard Castera - Explorations in Software Development
Richard Castera - Explorations in Software Development
Browsing Category
Resources Scripts

WordPress – List your most popular Posts

May 14, 2009 15 Comments

This function below creates a list of links of the top commented posts on your WordPress blog. It builds this list based on the posts that have the most comments. Place it in your footer or sidebar item!

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
function listPopularPosts() {
    global $wpdb;
    $strBuidler = '';
    
    $result = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
    
    foreach ($result as $post) {
    setup_postdata($post);
    $postId = $post->ID;
    $title = $post->post_title;
    $commentCount = $post->comment_count;
        
    if ($commentCount != 0) {
        $strBuidler .= '<li>';
        $strBuidler .= '<a href="' . get_permalink($postId) . '" title="' . $title . '">' . $title . '</a> ';
        $strBuidler .= '(' . $commentCount . ')';
        $strBuidler .= '</li>';
    }
    }  
    
    return $strBuidler;
}
?>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Update your Twitter status using PHP

May 13, 2009 18 Comments

Twitter is an awesome service! I use it on a daily basis and have grown addicted to it. Posting to twitter VIA an application is something that I’m sure you’ll need to do at some point. Using this simple little script below, you can post updates to twitter accounts fairly easily. Don’t forget to add your username, password and message below.

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Groovy – a programming language to look into

May 12, 2009 1 Comment

So what is Groovy? Groovy is like a super version of Java. It can leverage Java’s enterprise capabilities but also has cool productivity features like closures, builders and dynamic typing. If you are a developer, tester or script guru, you have to love Groovy. Below are some of it’s features.

  • Is an agile and dynamic language for the Java Virtual Machine
  • Builds upon the strengths of Java but has additional power features inspired by languages like Python, Ruby and Smalltalk
  • Makes modern programming features available to Java developers with almost-zero learning curve
  • Supports Domain-Specific Languages and other compact syntax so your code becomes easy to read and maintain
  • Makes writing shell and build scripts easy with its powerful processing primitives, OO abilities and an Ant DSL
  • Increases developer productivity by reducing scaffolding code when developing web, GUI, database or console applications
  • Simplifies testing by supporting unit testing and mocking out-of-the-box
  • Seamlessly integrates with all existing Java objects and libraries
  • Compiles straight to Java bytecode so you can use it anywhere you can use Java
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources SEO

How does Google compile the list of links below some search results?

May 11, 2009 1 Comment

The links shown below some sites in Google’s search results, called sitelinks, are meant to help users navigate your site. Their systems analyze the link structure of your site to find shortcuts that will save users time and allow them to quickly find the information they’re looking for.

They only show sitelinks for results when they think they’ll be useful to the user. If the structure of your site doesn’t allow thier algorithms to find good sitelinks, or they don’t think that the sitelinks for your site are relevant for the user’s query, they won’t show them.

At the moment, sitelinks are completely automated. They’re always working to improve their sitelinks algorithms, and may incorporate webmaster input in the future.

Referenced from: Google.

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

J-Crop – the jQuery image cropping plugin

May 10, 2009 No Comments

Jcrop is the quick and easy way to add image cropping functionality to your web application. It combines the ease-of-use of a typical jQuery plugin with a powerful cross-platform DHTML cropping engine that is faithful to familiar desktop graphics applications.

Feature Overview

  • Attaches unobtrusively to any image
  • Supports aspect ratio locking
  • Supports minSize/maxSize setting
  • Callbacks for selection done, or while moving
  • Keyboard support for nudging selection
  • API features to create interactivity, including animation
  • Support for CSS styling
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

How to Fix “Internet Explorer Cannot Open the Internet Site- Operation Aborted” Error

May 9, 2009 91 Comments

This error shows up when the page loads (or tries to load). There are many scenarios that can cause this error which occurs in IE. Microsoft has even issued a patch for solving it.

This error is being caused by calling a piece of Javascript within a page (after the tag). Adding the defer=”defer” tag to the script quickly resolves the issue.

JavaScript
1
<script defer="defer" type="text/javascript" src="src goes here">/*code goes here*/</script>

Hope this helps someone! 🙂

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Magento – Get the current theme folder

May 8, 2009 No Comments

If you ever needed to retrieve the path to your theme folder, you can easily do this by calling this function:

PHP
1
<?php echo $this->getSkinUrl(''); ?>

The code above will return something similar to: http://www.yoursite.com/skin/frontend/default/default/

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Magento – Retrieving Base URL Path

May 8, 2009 14 Comments

Anyone needing to retrieve the base URL path from Magento, just place this one line of code and there you have it! Hope this helps someone.

PHP
1
<?php echo Mage::getBaseUrl(); ?>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Creating a TinyURL with the TinyURL API

May 8, 2009 22 Comments

The popular URL shortening service TinyURL provides a quick API that creates TinyURL’s on the fly. Here’s how you can access that API.

PHP
1
2
3
4
5
6
<?php
function createTinyUrl($strURL) {
    $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=" . $strURL);
    return $tinyurl;
}
?>

Make a call to our function above, and it outputs a new tinyURL.

PHP
1
<?php echo(createTinyUrl('https://www.richardcastera.com/2009/05/09/creating-a-tinyurl-with-tinyurl-api/')); ?>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

WordPress – Embed Adsense in your posts

May 7, 2009 5 Comments

Adding Google Adsense to your blog’s post is easy. No need to download and add another plugin to your WordPress installation. Just follow these easy instructions! First, you have to add the following code to your theme’s functions.php file.

PHP
1
2
3
4
5
6
7
8
9
10
11
12
<?php
function showAds() {
    return '<script type="text/javascript">
    google_ad_client = "pub-2102064382433354";
    google_ad_slot = "5772977330";
    google_ad_width = 468;
    google_ad_height = 60;
   </script>
   <script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';
}
add_shortcode('myadsense', 'showAds');
?>

Saved the functions.php file and upload it. Now you can embed an Adsense unit into your posts easily by pasting the following code in the editor, in html mode:

XHTML
1
[myadsense]
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Page 8 of 11« First...«78910»...Last »

About me

Hello, my name is Richard Castera. I have more than 12 years of experience architecting, implementing, leading and launching large scale, high performance software products in a fast-paced agile environment.

Popular Posts

Magento – Display new products on the home page

May 20, 2009

How to Fix “Internet Explorer Cannot Open the Internet Site- Operation Aborted” Error

May 9, 2009

PHP – Convert Array to Object with stdClass

July 5, 2009

Categories

  • Home Automation
  • Resources
  • Scripts
  • SEO
  • Thoughts
  • Web Server

Tags

Apache Apple Bash CSS Drupal Free home automation htaccess Java Javascript Magento PHP raspberry pi SEO SQL thoughts Wordpress

© 2019 copyright Richard Castera // All rights reserved