• Home > Posts tagged 'php'

Posts Tagged ‘php’

Removing a Category from WordPress 3.1 RSS Feed

Sunday, February 27th, 2011

I filter a category out of my WordPress RSS feed because it’s all my tweets from the week.  I want an archive (mostly for myself) but I don’t want to blast anyone following my RSS feed with them every week.  I’d been using code like this in functions.php in my theme to screen them…

  1. function myRSSFilter($query) {
  2. if ($query->is_feed) {
  3. $query->set('cat','-100');
  4. }
  5. return $query;
  6. }
  7.  
  8. add_filter('pre_get_posts','myRSSFilter');

 

Where the category has an ID of 100 so you put -100 in the code.

This doesn’t work in WordPress 3.1 and I’d not come across a fix so I did a bit of experimenting and found that this code seems to remove the unwanted category from the feed…

  1. function myRSSFilter($query) {
  2. if ($query->is_feed) {
  3. $query->set ('category__not_in', '100' );
  4. }
  5. return $query;
  6. }
  7.  
  8. add_filter('pre_get_posts','myRSSFilter');

 

function myFilter($query) {
    if ($query->is_feed) {
        $query->set('cat','-99');
    }
return $query;
}
  1. function myRSSFilter($query) {
  2. if ($query->is_feed) {
  3. $query->set('cat','-100');
  4. }
  5. return $query;
  6. }
  7.  
  8. add_filter('pre_get_posts','myRSSFilter');

add_filter('pre_get_posts','myFilter');

One Page Can Make a Difference

Monday, August 16th, 2010

The original Knight Rider used to end with the refrain of Wilton Knight’s last words to Michael…

One man can make a difference

Tonight I thought I’d share how one page (and a tiny bit of PHP code for WordPress) made a difference to my site.  At least its made a difference for Google.  I’ll apologise for the over stretched Knight Rider references now.

I’d noticed in Google Webmaster tools that around five hundred of my site’s pages were no longer in the Google index that used to be.  I’m not sure if this was the result of Google’s Caffeine launch but the timing of the fall is quite close. I’d also seen a 5% drop in visits to the site but that could be just a random fluctuation in the numbers.

There are some pages I exclude deliberately using robot meta tags like tag index pages and category pages.  They don’t have any useful content so I didn’t want to risk a duplicate content penalty.  Even deducting those from the total number of missing pages and 300+ pages were no longer in the index.

A bit of investigation (the obligatory bit of any Knight Rider episode where Michael would wander round a warehouse filled with cardboard boxes with a torch) and deduction hinted that the missing pages were old blog posts.  The missing ones were buried deep in the blog.  They are in the XML sitemap but Google’s spider just wasn’t getting deep enough through links to think they should be in the index. I’d trusted the sitemap to keep real content in the index but it doesn”t seem to be doing that anymore.  The XML sitemap had become C.A.R.R. to my site’s K.I.T.T!

I can’t just drive into the back of the FLAG mobile unit and get Bonnie to fix the problem.  I had to come up with a solution for myself.  So I added a rather uninteresting Too Many Ideas Contents page that lists every page on my blog by title. It was pretty easy to set up in WordPress with a little bit of code in a plug-in…

  1. function show_all_posts($atts) {
  2. $posts = get_posts('numberposts=-1&orderby=title&order=ASC');
  3.  
  4. foreach($posts as $post)
  5. {
  6. $text.='<li><a href="'.$post->post_name.'">'.$post->post_title.'</a></li>';
  7. }
  8.  
  9. return '<ul>'.$text.'</ul>';
  10. }
  11.  
  12. add_shortcode('show_all_posts', 'show_all_posts');

I dropped the [show_all_posts] shortcode into a page and magically the list appeared.

Then all I had left to do was wait and see if it worked…

The impact was like Michael hitting Turbo Boost – the day after I published the page Google indexed 500+ pages on my site rather than the 200 it was doing in June and July.  Its done that every day for a week now and the number of pages has actually risen slightly to a high of 617 pages.

The 300 missing pages are now back in Google’s index so I think I can safely say…

One Page Can Make a Difference

Too Many Things

Tuesday, May 26th, 2009

I think I need a few extra hours in the day – if I did each of the following would probably be its own post…

Having finished a fascinating book on illegal gambling in the UK in the ’50s I started reading the first volume of Michael Palins’ diaries on Saturday and there a great read…

One unfortunate combination of words set an idea for a humorous, slightly strange Murder Mystery short story idea off and I wrote the first four pages yesterday…

That stopped me finishing the longer game writing project thats so close to having a complete first draft its bugging me…

So I was going to tackle it in the evening but I got an e-mail with an offer from Cornucopia3D for GeoControl2 which I’ve been tempted by for a while. So I ended up playing with that instead…

Plus Kim’s got a new novella out, Flesh and Shadows, with a very cheesy cover but I’ll probably give it a read because despite the cover its supposed to be Science Fiction not Mills and Boon…

Oh and having decided not to take out a subscription to the new version of Pyramid magazine because now its themed of the first six issues I’d only found three I was interested in. So inevitably the latest issue is one I wanted to pick up…

Then there’s the vue video tutorial from Quadspinner I want to write a review of for my Vue News Blog

I’m just glad that The Wire (which is good but not as good as some of its exponents would like us to believe) is on three nights a week so I know when its finished its time to get some sleep or I don’t know how I’d know to end the day.

Two Ragnarok Articles almost Ready to Go

Tuesday, March 10th, 2009

I’ve finished an article for Ragnarok, The Panzerfaüste Song Book, porting the shanty rules from Strange Grogge to Panzerfaüste and bringing the songs up to date. Needs a bit of checking before I send it off but hopefully its ok.

I’ve also just finished a short article for Ragnarok for the game Slag!. Three new systems and four ship designs using them. Need to make graphics for each of the designs but otherwise done. Frustratingly it would be done but when I finished the drawings last night the file not only failed to save but destroyed the earlier save in the process.

1 Comment »

Tags:
Posted in Wargaming, Writing |

Ragnarok 53

Tuesday, February 24th, 2009

Issue 53 of Ragnarok, the Society of Fantasy and Science Fiction Wargamings magazine, is out now and includes an article by me – When Ants Attack – for use with the game Tusk.

This issue, and the last three back issues are also now available from Wargames Vault as PDFs.

Just Messin' Around with Vue 7

Wednesday, November 12th, 2008

I’ve just spent the evening messing around with Vue 7. Nothing really to show from tonight but I made the yet to be titled picture above last night. I’ve resized it for the web from a larger, print quality render and cropped it a little too. The ship is from Cornucopia 3D and the Water Dragon from Daz. Vaguely inspired by my long since finished nautical Ravenloft campaign.

Did the Cliche Move for You?

Wednesday, February 27th, 2008

I wouldn’t be up this late but I’ve not been well and I can’t sleep. I was just doing the final rounds of checking on the flat when the whole building shook. At first I thought it was a Fire Engine going past outside at speed but from the way my inner ear was acting like I’d just gone through a railway tunnel I realised that wasn’t right. A quick google later and I found a USGS web site with some information about an earthquake in Lincolnshire. I’m going to try and go to bed again now while the Earths not moving…

2 Comments »

Tags: ,
Posted in Life Stuff |

Tonight I have mostly been playing with…

Thursday, December 13th, 2007

Tonight I have mostly been playing with the php5, the Zend Framework and the Gdata API. Nothing to show yet because I’m getting to grips with it although the impworks web site is now entirely php5 driven. Although thats not really very impressive as all I did was change a htaccess file so the php extension runs php5 instead of php4. Happily it all appears to be working without any hitches so far.

Wordless Wednesday

Wednesday, November 21st, 2007

On the side of St. George’s Hall, Liverpool

Thursday Thirteen #35

Thursday, November 15th, 2007


Thirteen songs Mark Caldwell found when sorting out old tapes recorded from the radio in my youth

  1. Boy Meets Girl – Waiting for a Star to Fall
  2. Bob Marley – Iron Lion Zion
  3. Beverly Craven – Promise me
  4. Tasmin Archer – Sleeping Satellite
  5. Jennifer Warnes – First We Take Manhattan
  6. Level 42 – Running in the Family
  7. Pearl Jam / Neil Young: Rockin in the free world
  8. Michael McDonald – Sweet Freedom
  9. Mark Cohn – Walking in Memphis
  10. tanita tikaram – Good Tradition
  11. Starship-Nothing´s Gonna Stop Us Now
  12. John Farnham – You’re The Voice
  13. Midnight Oil – Beds are Burning

Links to other Thursday Thirteens!

1. working at home mom
2. Malcolm
3. The Gal Herself
4. Chelle Y.
5. Comedy Plus
6. Tink
7. greatfullivin
8. Yuriko
9. Janet
10. nicholas
11. Crimson Wife
12. Susan Helene Gottfried
13. WorksForMom
14. SandyCarlson
15. CK Go Places
16. Lori
17. Rose
18. rhonda
19. Journeywoman
20. susiej
21. The Pink Flamingo
22. SJR
23. Wakela Runen
24. Serina
25. Natalie
26. Grace
27. Raggedy
28. Xakara
29. Emmyrose
30. Holly
31. Sharon
32. secret agent mama
33. Ann Aguirre
34. MamaLee
35. Tilly Greene
36. Maribeth
37. jayedee
38. Leigh
39. Samantha_K
40. Sarah
41. Cindy Swanson
42. darkdwarf
43. ellen b
44. Diana
45. katherine.
46. damozel
47. stella

Get the Thursday Thirteen code here!

The purpose of the meme is to get to know everyone who participates a little bit better every Thursday. Visiting fellow Thirteeners is encouraged! If you participate, leave the link to your Thirteen in others comments. It’s easy, and fun! Be sure to update your Thirteen with links that are left for you, as well! I will link to everyone who participates and leaves a link to their 13 things. Trackbacks, pings, comment links accepted!

« Older Entries