• Home > Posts tagged 'WordPress'

Posts Tagged ‘WordPress’

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');

Comments Spammer 404s Revisited

Tuesday, January 4th, 2011

I’ve been meaning to revisit my WordPress 404 Errors for Spam Comments but somehow it kept slipping through the cracks. I was at a bit of a loose end so I did a quick run through my spam comment log and my site’s error logs…

There were 424 spam comments to my site in December 2010. Of those 74 had an associated 404 error for the comment page that WordPress would have made had the comment been approved. All the comments and 404 errors that paired had IP addresses that matched. I’d say that suggests that the spambots are checking if they succeeded to get a comment posted rather than someone auditing to check the inbound links they’ve paid for exist.

The test for a comment page that causes the 404 error isn’t happening immediately so the bots have been coded to allow for comments being delayed. I can’t think of a reason a comment would be delayed other than moderation. Most of the comments are so blatantly spam that I can’t see most of them being approved. I did a quick sample of the ones I looked at the ones with long lists of links weren’t tested to see if they got through and the random garbage text with a couple of links were sometimes tested.

The most heavily checked spam comments were short like “A very interesting post thanks for writing it!” or “Thanks For the exelent info. I’ll be back in the future. Thanks again! [Link to drugs spam site]“. Maybe a few of the short ones like the second one might slip past someone who’s taken the drugs from the site linked to? I imagine some like the first one will get through on a high traffic blog with lots of comments to moderate.

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

WordPress 404 Errors for Spam Comments

Wednesday, May 5th, 2010

Ever since I rebuilt my website with WordPress and imported my blog from blogspot I’ve kept an eye on my server error logs.  I like to make sure people who arrive here from the old blog or from other links end up where they were looking to go. While I’ve redirects that catch almost all of the possible routes in I want to be sure and checking the error logs gives me a way to spot any I’ve missed.

I just went through last months logs.  Of the around 250 error pages served there was a rather annonymous blog page that needed redirection setting up for.  It accounted for 5 of the hits.  10 were typos or calls to deleted pages. 60 were bots trying crude hack attacks on the site trying known vulnerabilities in a variety of software. That left around 170 that I’d not been able to explain.  Every one a call to a comments page that when I checked didn’t exist. The address was a unique combination of a unique comment number and the page the comment had been posted on.

2006/02/more-thoughts-on-the-game-without-a-snappy-title/comment-page-1/#comment-9940

I’ve seen 404s like this for months and couldn’t work out why they were appearing.

Then it struck me what they were.  Those comment pages were for comments that Akismet caught as spam. The only way (short of brute force which would show up in the logs) that someone could know the combination of the comments unique ID and the page it had been posted on was to be the original poster (or the spam system that posted it) .  Those 404 pages must either be the spam bot coming back later to see if it worked or some other system running quality control before paying out for links to a site having been created.

I’ve not had a chance to match up spam messages to 404s because I keep my spam logs clear but I’m going to keep an eye on it and see if they support the idea.   I’m intrigued to see how often they check a comment, if they come fromt the same IP as the spam message and how long after posting they check.

Blogging Differently

Wednesday, September 16th, 2009

postgraph-ignore

I noticed awhile ago that I was blogging less.  Partly I put it down to frustration with the time it took me to add a page to my web site.  If I couldn’t easily add a page about something I didn’t need to blog about the page.  Partly it was a disatisfaction with the blog and site not being integrated.  Partly it was a concern about what I was blogging about.  I like posting about fun little discoveries – you tube videos, interesting web pages, announcement and all the other stuff thats going on.  However I was always picky about how much of it I posted.  I knew it could easily swamp out my own stuff in a huge noise to ratio disaster.  Its bad enough that I choose to post on several different themes I’m interested in rather than focusing on one theme.  Thats why I use categories and tags to classify my blog posts.

So I delt with the first two problems by switching my site to using WordPress as a Content Management System.  I know some people will say WordPress isn’t a CMS.  Frankly if it isn’t a Web CMS then every other Web CMS I’ve ever worked with isn’t either including the one those people are touting.  Yes it’s a blogging platform but that doesn’t stop it also being a CMS.

The third problem, the noise to content issue, I’ve pretty much put to rest by the happy accident of using microblogging.  Now I signed up to Twitter sometime in 2007 to see what all the fuss was about.  I didn’t really do anything with it till this summer when I needed to know about it for work (and probably foolishly removed my few early tweets since I was using it to test a development at work).  Anyway I’ve been using Twitter for a couple of months now for amongst other things the noise stuff and just consolidating the posts to my blog once a week.  Twitter has the added bonus that unlike blog comments, which tend not to end up being conversational because the lack of a consistent alerting system, twitter can have at least a bit of a discourse.

And the point of this post? I’ve no idea really.  Maybe that blogging, like the web, is still evolving.

Anyway I’m off to do something more useful instead.  Just as soon as I’ve checked Twitter…

Twitter Weekly Updates for 2009-08-16

Saturday, August 15th, 2009

Vue Stereo Image Camera Creation Script Page

Saturday, August 15th, 2009

So glad I switched this site to WordPress – adding new pages is so much easier.

Tonight I’ve added a new page for the simple Vue Stereo Image Camera Creation Script I wrote back in 2007.

Twitter Weekly Updates for 2009-08-09

Saturday, August 8th, 2009

Twitter Weekly Updates for 2009-07-26

Sunday, July 26th, 2009

Too Many (Uncategorised) Posts

Saturday, July 11th, 2009

Slogging slowly but surely though all my old blog posts categorising them so I can add better category based navigation now the sites all wordpressified.  Down from 250+ to less than 100 left to go.  Yeh!

Then I can start worrying about tagging the ones that haven’t got tags ;-)

« Older Entries