logo
Currently Browsing: PHP

Adding Meta Description Tags for Archive Pages in WordPress

logo

In order to track SEO metrics for my clients, I use the SEOMoz Pro service, which is a handy tool at monitoring SEO metrics (and so much more). I’ve noticed on one of the sites I manage through the service that I’ve been missing a number of meta description tags.  For those unaware, meta description tags are used to give a brief and concise summary of content on a page.  This helps search engines and potential readers understand what’s on the page.  The meta description info is also often used in page summaries in search results from engines like Google.  The below example is one from my music site, Electric Mohawk.meta description search example Adding Meta Description Tags for Archive Pages in WordPress

The example demonstrates the importance of meta description tags in SEO quite clearly.  I noticed, though, that some of my pages on Electric Mohawk are turning up as missing meta description info in their tags.  A prime example for my site is archive pages.  My sites are typically built using WordPress, so archive pages are dynamically generated and compiled, usually based on the month content was published.

I typically do not make my archive pages searchable for SEO purposes, but some people may still want them archived and may still want them to include a basic description.  The problem is, though, that many of us already use an SEO plugin of some sort, particularly All-in-One SEO Pack, where users do not get direct access to creating meta description tags for certain dynamically generated pages (any kind of archive page or page-navi generated page).  Another issue is that by creating another meta description tag to compensate for this in the header.php file would cause duplicate description tags to be created if the content is not an archive page.  I’ve created a simple workaround for WordPress archive pages to solve this problem.

Add this piece of code to your theme’s header.php file:

  1. <?php if (is_month()) {echo ‘<meta name="description" content="’; the_time(‘F, Y’); echo ‘ archive page for Electric Mohawk."/>’;}?>

What this code is doing is simple.  The if statement checks whether or not the page is an archive page. If it is an archive page, then it will echo out a portion of the meta description html tag.  In between, I made a call to the_time() function that passes in the month and year. I then created another echo that gives the actual description.

Some of you may be wondering why there are two echo statements instead of a simple string concatenation.  While I was debugging and testing out this code, the date would appear before the initial HTML tag, causing problems with formatting and validation.  Creating a second echo seemed to solve the problem.  Also, if the statement evaluates false, no additional tags will be generated.

I hope this snippet helps you out in some way. Have an alternative? Feel free to share!

Debug Flex and PHP Code Using Flash Builder 4

logo


Adobe Platform Evangelist Mihai Corlan discusses how to debug the code of a combined Flex and PHP project using Flash Builder 4 and Zend Studio 7.1. He reviews how to use breakpoints to test your application.

PHP 101 Part 4: Pythagorean Theorem, Math Functions, and Forms

logo

This is the 4th (and likely final) part of my PHP 101 series.  This series of videos include how to solve the Pythagorean Theorem using math functions in PHP, diving more into some of the math functions that PHP has to offer, and creating a form and replacing hard coded variables with arrays.

Pythagorean Theorem

Math Functions

Form Letter

To view other PHP tutorial videos

PHP 101 Part 3: Eclipse, Simple Math, Calculator

logo

This is part 3 of the PHP 101 series I’ve put together on my site.  this next round adds more complexity and shows you how to setup the Eclipse IDE for PHP development.

Eclipse

This video goes through the process of installing and setting up Eclipse for PHP development step-by-step.

Simple Math

This video demonstrates the basic mathematical capabilities of PHP.  Concepts include

  • Basic arithmetic operators (addition and subtraction)
  • Variables that handle math calculations
  • Troubleshooting Eclipse

Calculator

This video demonstrates how to build a basic math calculations using PHP. Concepts include

  • Basic arithmetic operators
  • Modulus
  • Integers vs Floating Point numbers

To view other PHP tutorial videos

PHP 101 Part 2: Variables, Strings, and String Functions

logo

Here is the second series of videos on the basics of PHP. Whether you’re a novice, or just brushing up, these videos will give you a more fundamental knowledge of the nature of programming in PHP. Today’s videos include variables, strings, and string functions.

Variables

This video covers the basics behind variables in PHP.  Concepts include:

  • Syntax
  • PHP variables compared to strict typed variables
  • Case sensitivity
  • variable of variables

Strings

This video is dedicated to string data types.  Concepts in this video include:

  • String variable declaration
  • String concatenation
  • Mixing numbers and strings (Only in PHP!)
  • Curly Brackets (similar to a Bindable expression in Flex)

String Functions

While this video focuses on PHP String functions, it focuses even more on learning more about PHP.  Included are resources on where to learn more about PHP.

To view other PHP tutorial videos

Page 1 of 212
logo
Powered by Wordpress. Copyright 2009 Brett Widmann.