Twitter Widget Pro and Jetpack Twitter widget can’t live together

Posted on: 21st February 2012 No Comments

I installed Jetpack for WordPress on my blog today, mainly because of the stats module, but also because I was considering changing the twitter widget I use. I have used Twitter Widget Pro for a while, and the reason for the possible change was mainly that the output was a bit clogged, since it outputted the twitter app the message was composed in, as well as the “normal” message output. The Jetpack twitter widget only outputs how long since the tweets were posted, all I wanted, so it seemed like a good and lazy switch, since it became available when installing Jetpack.

But did it really? Oh, no! The Jetpack twitter widget was missing in action from the widgets page on my WordPress installation. The needed files was physically (as physically a file can be, anyway) on the server, so a long series of troubleshooting followed. This included deactivating/re-sactiavting Jetpack, deleting and re-installing Jetpack, installing Jetpack manually, and so forth.

No Jetpack twitter widget for you

No Jetpack twitter widget for you!

It was not until I deactivated Twitter Widget Pro that the missing twitter widget showed itself. I don’t know the link between these two, but when deactivating Twitter Widget Pro, the Jetpack twitter widget automatically took it’s place in the right sidebar. So they are most likely sharing something they shouldn’t.

Hey, presto! A widget comes home.

Hey, presto! A widget comes home.

But in the end problem solved, and widget changed.



Breadcrumbs on archive pages in WordPress

Posted on: 21st February 2012 No Comments

When I was editing a WordPress archive page the other day, I decided that I wanted to list the categories and sub categories together with the archive result (the title with link), but without the links to the specific category pages. Some of the links on the archive page would have just one category, and some would have more, depending on the post. This is on a page that uses  WordPress as a CMS, not just for blogging.

The solution I came up with, used the wp_get_object_terms function, that I earlier had used together with a custom taxonomy query.  The categories are stored in the term ‘category’. To make sure the categories and sub categories was displayed in the right order (parent before sub), the output had to be ordered ascending (as the parent categories on this specific page all has a lover ID than the sub categories). And I used : as a separator between the categories and post title.

All entries included title, link, last change date, and the excerpt. The code ended up something like this:

<?php while (have_posts()) : the_post(); ?>
 <div <?php post_class() ?>>
 <h2 id="post-<?php the_ID(); ?>">
 <?php
 $args = array('orderby' => 'ID', 'order' => 'ASC', 'fields' => 'all');
 $category_terms = wp_get_object_terms($post->ID, 'category', $args);
 if(!empty($category_terms)){
 if(!is_wp_error( $category_terms )){
 foreach($category_terms as $term){
 echo $term->name.' : ';
 }
 }
 }
 ?>
 <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
 <p class="changed-archive">Last modified: <?php the_modified_date(); ?></p>
<div class="entry">
 <?php the_excerpt(); ?>
 </div>
  </div>
<?php endwhile; ?>

Which gave this output (in Norwegian, mind):

Archive page with breadcrumb trail

Archive page with breadcrumb trail

I’ve also ended up using this solution on my post pages as well, but then combined with links.



Disappearing page templates thanks to bad taxonomy naming

Posted on: 5th February 2012 No Comments

On one of my other sites, I’ve recently transferred all the old, static content into a WordPress installation, so that I can WordPress as a CMS. The content is divided into five main categories, and for each category I’ve created a custom page template. The main menu links to the category pages, making them “category portals”, so to speak. And it looks good.

But yesterday, WordPress stopped using the custom page templates, and defaulted to index.php on all of my pages. But in the admin area, the pages were still listed as using the templates, and the files were actually still on the web server. I tried to upload the theme once more, without it helping, and also reinstalled WordPress through the Dahboard -> Updates screen without result. It was not until I turned off and on again my custom permalink structure that it went back to normal. My custom structure was /%category%/%postname%/ and choosing default, saving, and choosing custom structure once more, solved it. Or so I believed.

Because this morning, the custom page templates did once again not work. And I had to turn the custom structure off and on again to make it go back. And it was ok for about ten minutes, before defaulting back to the index.php again.

After some time looking angrily at my screen, it dawned on me that it might have something to do with my custom taxonomies. I had set up a taxonomy named year, that i used for the posts. In retrospect, not a very good name for a taxonomy. I had not managed to get any output for this taxonomy yet, and had kind of given up yesterday. Not one before I discovered the defaulting. So I deleted the taxonomy from the functions file, and no the problem seem to be solved.

So the moral of the story has probably something to do with naming conventions. Well, well…



Displaying custom WordPress taxonomy terms with or without links

Posted on: 22nd January 2012 No Comments

WordPress lets you create custom taxonomy terms, a feature that makes WordPress a very good CMS. If you want to display these terms (on a specific post), there are more than one way to do this.

If you want to list the terms associated with a specific post with a link to a term archive, you can use the get_the_term_list() function. This displays the terms (including a term link). To run through the terms, use code similar to this (from the codex):

<?php echo get_the_term_list( $post->ID, 'people', 'People: ', ' ', '' ); ?>

But if you want to display the terms without the links, you can use code similar to this, using wp_get_object_terms():

$people_terms = wp_get_object_terms($post->ID, 'people');
if(!empty($people_terms)){
  if(!is_wp_error( $people_terms )){
    echo '<ul>';
      foreach($people_terms as $term){
      echo '<li>'.$term->name.'</li>';
      }
    echo '</ul>';
  }
}

To display all the terms, regardless of the specific post, you can use the get_terms() function. Code similar to this lists the terms in a unordered list

<?php
$terms = get_terms("people");
 $count = count($terms);
 if ( $count > 0 ){
     echo "<ul>";
     foreach ( $terms as $term ) {
       echo "<li>" . $term->name . "</li>";
     }
     echo "</ul>";
 }
?>


Updating iOS 5 with the new over-the-air update function

Posted on: 10th November 2011 No Comments

Today, Apple released the first iOS 5 update, updating from 5.0 to 5.0.1, fixing the battery problem. And this was the first chance to use the new over-the-air update, meaning updating the iOS without plugging it into a computer. So how does it work? Let me show you.

If you don’t get a pop-up telling you about the update, you can go look for it by choosing Settings -> General -> Software Update on your iOS device. Your device will perform the check, and show you the result. If it finds an update, just press Download and install, and the process is pretty self explanatory.

Updating iOS over-the-air

Starting updating iOS over-the-air

You must have over 50% left of your battery, or be plugged into a socket, to do the update,

Updating iOS over-the-air

Finishing updating iOS over-the-air

Unlike the previous updates, this update just sends you the updated parts, not everything as it used to do.

Worked like a charm.