Exclude SlideDeck posts in WordPress

Tags: , , , ,

On a WordPress site I’ve been working on I’m using SlideDeck as a feature article slider on the homepage.  The only problem was I have additional articles populating underneath it and the articles from the SlideDeck were showing up down there as well.

We didn’t want that behavior so I researched how to filter out SlideDeck posts from the post loop.  At this time, it’s apparently easy to filter for content that has a custom meta-tag, but you can’t easily filter for content that doesn’t have a custom meta-tag applied to it.  It’s because when a post doesn’t have a custom met-tag attached to it that custom meta-tag doesn’t come up as “null” or “0”  it simply doesn’t come up at all.  So there’s no way to use query_posts to filter out SlideDeck posts, you have to make custom database query and use $wpdb->get_results.

This post from SlideDeck’s customer support website did most of the heavy lifting for me in putting together the exact query I needed to filter out only SlideDeck posts.  The only problem was that this gave me no insight as to how I could paginate the posts.  Thankfully google came to rescue once again and I found this post and this post which helped me piece together the script.  I posted my findings on SlideDeck’s customer service website, but I’m posted it here as well so I can easily find it again if I need it.

So for the code, inside loop.php before have_posts() I put…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if(is_home()) {
    //query_posts(array( 'meta_key' => 'slidedeck_post_featured') );
    global $wpdb;
    $ppp = intval(get_query_var('posts_per_page'));
 
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $offset = ($paged-1) * $ppp;
    $sql = "SELECT p.*
        FROM {$wpdb->posts} AS p
        LEFT JOIN {$wpdb->postmeta} AS pm
        ON pm.post_id = p.ID AND pm.meta_key = %s
        WHERE p.post_status = %s AND p.post_type = %s AND pm.meta_value IS NULL
	ORDER BY p.post_date desc
        LIMIT $offset, $ppp";
    $posts = $wpdb->get_results($wpdb->prepare( $sql, '_slidedeck_post_featured', 'publish', 'post' ));
}

if(is_home())  will make it so it will only filter out SlideDeck posts on the homepage, and apparently the have_posts() works exactly as it normally does even when I change the loop using $wpdb->get_results, which means I don’t have to do much to the rest of the page in order for this to work.  WordPress, you rock <3

This will paginate the posts according to the number of items I have set in the WordPress settings, but for some reason when I did this on the last page it printed out empty posts to fill out that page.

For instance, say I only have 7 posts left on the last page, but I have it set to show a maximum of 10 posts per page – it would print out 3 empty posts on that page.

To combat this I put the following code inside have_posts() so it wouldn’t print anything if the post ID was null.

1
2
3
if(get_the_ID() > 0) {
    //html for posts
}

Pretty straight forward and everything has been working great so far :)

 

References

http://support.slidedeck.com/slidedeck/topics/wp_query_a_list_of_posts_not_featured_in_the_slide_deck?from_gsfn=true

http://wordpress.org/support/topic/custom-loop-pagination

http://www.scriptygoddess.com/archives/2011/02/23/wordpress-pagination-woes-solved-i-hope/

Permalink » No comments

Free certifications from Gild

Tags: , , , , , ,

I was looking at those pricey w3schools certifications, but everywhere I asked said it was a big waste of money. So I decided to see what alternatives there were and see if there were any certifications that were especially well know that I should take.

What I did find was the Gild website where you can get certifications for free!

The price is right, and if I learn something along the way then I say it’s definitely time well spent.  I am still considering the w3schools certifications, but I’m going to start out with the free ones from Gild and see where that takes me.

http://www.gild.com/

Permalink » No comments

Server side scripting statistics

Tags: ,

I found myself a bit curious as to what server side scripting languages people are using out there.  After mulling around google I found a few suggestions to do a job search to get an idea of the demand for different scripting languages.  I came across this post from August 25, 2008 and thought I would repeat the analysis by searching for “Ruby on Rails”, “PHP”, “ASP.NET” in the same job sites as the previous blogger.  These are all searched for in “San Francisco, CA” like the original post.

SiteRoRPHPASP.NET
2008
Monster.com23216135
Career Builder1712367
Hot Jobs31521107
total71860309
2010
Monster.com325935
Career Builder306236
Hot Jobs6530747
Total127428118
Craigslist6629240

I was pretty surprised to see the dramatic difference in Hot Jobs than from the other two.  I thought it might have something to do with the cost of using the job site itself, so I decided to throw in Craigslist – which gave similar results(I did have to remove the “.” on craigslist – a bug?).  So maybe PHP employers are “cheaping out”  on their recruitment services.

PHP still comes out ahead *whew*, but it seems ruby is on the rise.  What is most distressing though is that the total amount of job listings is almost half of what it was two years ago!  A little scary.

ADDITION: JULY 1, 2011

Alright, it’s a year later and I’m back again to make the same comparison! :)  However, since last year Yahoo! Hot Jobs has gone out of business :(  That makes me pretty darn happy I decided to add in Craigslist last year, and now I’m also adding in the technology focused job site “Dice” in case another of the other jobs listing sites goes under for next year’s comparison.

SiteRoRPHPASP.NET
2008 total71 (5%)860 (69%)309 (24%)
2010 Total193 (18%)720 (67%)158 (14%)
2011
Monster.com25 232
Career Builder5013370
Craigslist150831160
Dice149521159
Total374 (16%)1508 (66%)391 (17%)

This year I calculated the percentages for the totals to make the data a little easier to assess, and I used “ASP NET” for Craigslist like last year.  Monster is the only site that has RoR in the lead. It’s distressing, but according to this data, it looks like PHP has slowly been loosing ground at a steady pace of 1% a year.  RoR came up a lot between ’08-’10, but has lost a little ground this year.  ASP.NET has recovered a bit since last year, but still isn’t back to where it was in ’08.  Mashable dubbed 2011 as the year of Ruby, but these numbers arn’t too convincing.  I’d rather see PHP gaining ground, but it’s still strong at 66%.

As far as the total number of jobs goes – things are looking up since last year. Career builder and Craigslist both have more job listings then they did last year.  Dice and Craigslist have a lot more listings then the others, but I think they just use a larger search radius. One interesting point is that Monster is the only site to have less listings from last year, though I feel it may be more due to Monster rather than a reflection of the job market.  Monster may also deal more with higher paying jobs, which could be why their numbers are so different then the other sites.  These numbers might also be a reflection that, while there are less of positions available, RoR has a higher pay grade than PHP.  Which isn’t too much of a stretch considering that lack of support for RoR and that RoR has a steeper learning curve than PHP.

ADDITION: JULY 2, 2012

SiteRoRPHPASP.NET
2008 total71 (5%)860 (69%)309 (24%)
2010 Total193 (18%)720 (67%)158 (14%)
2011 Total374 (16%)1508 (66%)391 (17%)
2012
Monster.com37 (60%)21 (34%)4 (6%)
Career Builder21 (14%)87 (56%)47 (30%)
Craigslist144 (16%)698 (76%)77 (8%)
Dice200 (21%)590 (62%)159 (17%)
Total402 (19%)1396 (67%)287 (14%)

About 200 less jobs then last year, but still double of what was available in 2010. Although it looks like the percentages are a little closer to what they were in 2010, but all in all not a lot of variation. It looks like PHP has been steadily the most popular, with RoR and ASP fighting for 5% of the market share.

ADDITION: JULY 2, 2013

SiteRoRPHPASP.NET
2008 total71 (5%)860 (69%)309 (24%)
2010 Total193 (18%)720 (67%)158 (14%)
2011 Total (2273)374 (16%)1508 (66%)391 (17%)
2012 Total (2085)402 (19%)1396 (67%)287 (14%)
2013
Monster.com27 (42%)28 (43%)10 (15%)
Career Builder24 (12%)80 (41%)91 (47%)
Craigslist185 (23%)522 (65%)100 (12%)
Dice160 (19%)479 (58%)183 (22%)
Total (1889)396 (21%)1109 (59%)384 (18%)

Again, 200 fewer jobs then last year.  A bit of sobering news there…  With PHP waning and RoR growing a bit in popularity, and ASP.NET just looks like it keeps going up and down..

ADDITION: JULY 1, 2014

SiteRoRPHPASP.NETPythonPerl
2008 total71 (5%)860 (69%)309 (24%)
2010 Total193 (18%)720 (67%)158 (14%)
2011 Total (2273)374 (16%)1508 (66%)391 (17%)
2012 Total (2085)402 (19%)1396 (67%)287 (14%)
2013 Total (1889)396 (21%)1109 (59%)384 (18%)
2014
Monster.com70 (35%/12%)102 (51%/17%)29 (14%/5%)276 (45%)129 (21%)
Career Builder30 (11%/6%)177 (64%/34%)68 (25%/13%)155 (29%)98 (19%)
Craigslist167 (19%/10%)593 (69%/37%)97 (11%/6%)557 (34%)205 (13%)
Dice145 (22%/6%)390 (58%/15%)135 (20%/5%)1179 (46%)698 (27%)
Total (2003/5291)412 (21%/8%)1262 (63%/24%)329 (16%/6%)2167 (41%)1121 (21%)

This year I’m adding on two new languages, Python and Perl. I keep seeing Python here and there, and there’s even a course for it on codeacademy.com right now. I’m thinking of looking into that so I wanted to start tracking it…and Perl is there just for the lols. But, this messes up the numbers a bit, so I have totals and percentages that just include PHP, RoR, and ASP.NET so I can compare those to last year’s numbers.

Total jobs are up by 114 according to last year :) Only gained about half what was lost compared to previous years, but that’s nice to see things going up.

RoR has stayed the same, while PHP has taken a 2% chunk out of ASP.NET. Over the years, it looks like RoR has been slowly gaining popularity, while ASP and PHP just kinda fluctuate a lot.

Adding in Python was really surprising, it’s the most popular language here. And it has quite a decent margin over it’s peers as well, PHP is the next popular, but it’s only 4% greater then half of the amount of Python jobs available. I’m thinking this may be because Python isn’t limited to web development, and there are software development jobs using the language as well. However, I’m not particularly knowledgeable about the language and I’m very interested in learning more about it.

Perl is a bit interesting as well, I tend to think of it as a dying language, but there are more than twice as many jobs in Perl as there are in RoR. I do assume that the demand of Perl is due to maintaining older systems that still use the language, but there’s still a decent demand for Perl coders.

Permalink » 2 Comments

Javascript Zoom In

Tags: , , ,

For a project I wrote this JavaScript based image zoom in application.   At the time I couldn’t find anything out there that I could use to get the desired effect (at least w/out shelling out some dough) – so I opted to write something myself.

The entire idea was not well received…so I never actually finished it.   So this is essentially just a “proof of concept”.  It demonstrates that you can zoom in, zoom out, and move an image around within a specified area without the use of flash.  I don’t know if I’ll ever get the chance to finish this, or really even have a reason to finish, but so it doesn’t get lost I thought I would post it up here.

Regardless of the outcome it was a good exercise in JavaScript :)

Click here to see it in action!

The zoom icons used in this are from Dry Icons

Permalink » No comments

Special Character Converter

Tags: , , , , ,

I’ve created a very, very, simple online converter for special characters.  I’ll often get handed off a Word document with text to be included in a website.  Word by default will create curly quotes, and it may have a myriad of special characters littered in there.  So I made a simple script that replaces special characters with their ASCII entity counterparts.

You Simply copy and paste the text into the large textbox, click on the button and voila!  It does have some limited conversion of ampersands.  It will only convert and ampersands to &amp; if there is a space in from of it to remove the risk of converting any entities that may be already in the code.  So while “Tea & crumpets” will convert “M&M” won’t.

Special Character Converter

Permalink » No comments