Tag Archives: PHP

Twitter Timelines Removed from My Websites

Update July 25, 2023: Well, it seems that if you are logged into Twitter, you can see the embedded profile timelines now. However, I just realized that if you are not logged into Twitter, you still just see the “Nothing to see here – yet” message. So, it still makes it not worth including them in my eyes. Ergh.


Well, whatever Twitter has done recently to not allow you to view tweets unless you are logged in (which may or may not still be case) has possibly caused the embedding of profile timelines (showing tweets you’ve made) to not work. The all seem to come back with a message of “Nothing to see here – yet” . There must be more than just requiring to be logged in, since I am logged in. In fact, it doesn’t even work on their own Twitter Developer Platform Timelines page.

Until they get it working again or come up with some different process, I have removed these timeline widgets from my Blog, Main Website, and Mysstie site.

Related to this, I have also stopped importing my tweets into my blog for some time (Daily Tweets category) and automatically sending new blog post notifications to Twitter as they have suspended all of my PHP script based applications. This has also affected my ability to automatically send new gallery image notifications to Twitter. They now have a new API structure set up which I’m just not going to sign-up for due to the costs. 😮

It all kind of just sucks and we’ll have to wait and see where it all ultimately settles out. I will continue to use Twitter but in more a manual process, LOL. On a side note, I hope everyone one had a great 4th of July! πŸ™‚

My Websites Might Crash Tomorrow

This is just a quick note to say that my websites might quit working or start acting weird later tonight or tomorrow. Actually, most were generating 500 Internal Server errors already today.  I corrected that issue so I can make this post now. The reason is that my webhost, Surpass Hosting is upgrading the server to one of the PHP 5.4 versions from 5.3.28. Oh boy.. πŸ™‚

How To Exclude Categories in WordPress Archives Drop-down

This is a follow-up post to my Excluding Categories from Different Parts of WordPress post a while back. The problem I was having is that the posts in my Testing and Daily Tweets categories where being counted and shown in the Archives drop-down widget. For example, it showed 4 posts in April 2011. When selecting April 2011 in the drop-down, you would get the “404 Not Found” page since all 4 posts belonged in the Daily Tweets category which is excluded from showing in the main blog, except when being accessed via the Category drop-down.

After some searching, I found the following thread: wp_get_archives and Conditional Tags and adapted the code as follows in my theme’s functions.php file:

add_filter( 'getarchives_where', 'customarchives_where' );
add_filter( 'getarchives_join', 'customarchives_join' );

function customarchives_join( $x ) {

   global $wpdb;

   return $x . " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";

}

function customarchives_where( $x ) {

   global $wpdb;

   // 61 = Daily Tweets, 74 = Testing
   $exclude = '61,74'; // category id to exclude

   return $x . " AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id NOT IN ($exclude)";

}

Now, it does not count those posts in the Archives drop-down. Yay! πŸ™‚

Blog Upgraded to WordPress v3.5 and Twenty Twelve Theme

I’ve upgraded my blog from WordPress v3.4.2 to v3.5 and changed over to the new default Twenty Twelve theme within the last day or so. The process went as follows:

  • Backed up the existing file structure and database on both my local development copy (I have Apache, MySQL, and PHP installed on my PC) and the one you’re viewing now.
  • Updated a couple of my plug-ins that had new versions out.
  • Updated the Twenty Ten and Twenty Eleven themes that had newer versions (I suspect to work better with the newer version of WordPress).
  • Ran the automatic upgrade to go from WordPress 3.4.2 to 3.5 which took around 10 seconds to complete.
  • Did my usual modification of the /wp-includes/vars.php file to force $is_apache to true so I don’t have to rely on the software to detect something which I know is true:
    // Server detection

    /**
     * Whether the server software is Apache or something else
     * @global bool $is_apache
     */

    // $is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);
    $is_apache = true;

As far upgrading the WordPress core itself, that’s really all there was to it. The rest centered around working with the new Twenty Twelve theme and tweaking it to my liking. The following outlines some of the major points during my initial testing and theme tweaking:

  • The first thing I did was create a Twenty Twelve child theme and placed in an appropriate style.css (you have to) and copied over the functions.php file from my Twenty Eleven child theme. I also copied over the Twenty Twelve’s header.php and footer.php files as I knew I would be modifying them.
  • Activated my new child theme and looked at the main page. This first thing I noticed right off was that each post had a duplicate image. There were two Happy Thanksgiving images, two Veterans Day images and so on. Went poking around on the WordPress.org forums and found the reason. I needed to modify the theme’s content.php file and comment out (or remove) a line that contained the_post_thumbnail(); as follows (I modified the copy that I placed into my child theme):
17
18
19
20
21
22
23
24
         <?php
         // this was causing the featured image to show in the post:
         /* if ( ! post_password_required() && ! is_attachment() ) :
            the_post_thumbnail();
         endif;
         */
?>
         <?php if ( is_single() ) : ?>
         <h1 class="entry-title"><?php the_title(); ?></h1>

That corrected the duplicate image problem. Since I had included the post’s featured image within the post’s content, this was causing it to display again.

During this image testing, I discovered that my Gallery3 Picker plug-in had stopped working. It was not showing a Gallery3 tab in the add Media window. As it has been 2 years since any updates were made to it and the fact that I really didn’t need it. I just got rid of that plug-in.

At this point things seemed to be OK and I began to modify the child theme’s header.php and footer.php files and tweak the theme’s options (background, header, menus, widgets, etc) and CSS to suit my needs. It was during this that I noticed a lot of words at the end of a line of text were being broken up with hyphens. I’m thinking to myself, “What’s up with that!?”. I right-clicked where the text was and inspected the element to see what CSS was associated with it (using Firefox 17.0.1 in Windows 7 Pro 64bit) and this is what I saw related to word-wrapping:

.site-content article {
   word-wrap: break-word;
   -webkit-hyphens: auto;
   -moz-hyphens: auto;
   hyphens: auto;
}

Well, I was having none of this so I added the following to my child theme’s style.css file to over-ride it:

.site-content article {
   word-wrap: break-word;
   -webkit-hyphens: none;
   -moz-hyphens: none;
   hyphens: none;
}

That stopped the hyphenations from occurring while still breaking up really long words that are too big for the width of the post’s content. For more information about this hyphenation business: Mozilla Development Network: hyphens.

That’s been the major stuff worth noting. The other CSS tweaks for font colors and such are just personal taste and everyone’s going to have their own opinion on what looks the best. πŸ™‚ If I discover some other bizarre thing related to the upgrade or new theme I’ll make a post then.

Excluding Categories from Different Parts of WordPress

Update January 18, 2016: Thought I would mention that if you also want to remove the categories from the Archives drop-down, check out my How To Exclude Categories in WordPress Archives Drop-down post.

Update January 24, 2015: I discovered a bug with the code below. I added an is_admin() exception so the post listings in the admin section would still work properly. Without the exception, the Category filter would fail to work. I actually created a WordPress Support thread when I noticed it.


For the longest time I had been using the Advanced Category Excluder plug-in to keep a couple post categories from showing on the blog’s home page, RSS feed, search, and monthly archive views. Well, after my webhost upgraded the server to PHP 5.3.17 from PHP 5.2.X it broke that plug-in. After searching around for some answers, I tried out the Simply Exclude plug-in which did work; however, it had a couple issues. One problem was that if I excluded a category from showing in the archive view or the category drop-down widget, it broke the permalink for categories where the address bar would show /?cat=6 instead of /category/dentist/ for example. It also excluded the category from both the monthly archive view and the category view itself. I did some more searching around and came across this WordPress Codex article about Category Exclusion. I adapted the code there and placed the following 8 lines of code into my theme’s functions.php file (info on using a theme’s functions.php):

function remove_my_categories( $wp_query ) {
  // 61 = Daily Tweets, 74 = Testing
  $remove_cat = '-61,-74';

  // remove from archives (except category archives), feeds, search, and home page, but not admin areas
  if( (is_home() || is_feed() || is_search() || ( is_archive() &amp;&amp; !is_category() )) &amp;&amp; !is_admin()) {
    set_query_var('cat', $remove_cat);
    //which is merely the more elegant way to write:
    //$wp_query-&gt;;set('cat', '-' . $remove_cat);
  }
}

add_action('pre_get_posts', 'remove_my_categories' );

That’s all I needed to exclude those categories’ posts from showing on the home page, RSS feeds, search results, and the monthly archives! I can still select the category from the category drop-down list and view it in the category context. Needless to say, I’ve removed both of those plug-ins from my blog.

Hopefully this information will help some others out that run into a similar situation. πŸ™‚