Quantcast
Viewing latest article 4
Browse Latest Browse All 29

Add SEO Data and Featured Image To WordPress Admin Page and Post List View

One of the nice things that the All-in-One SEO Pack does is add some new columns to the WordPress admin list views for pages and posts, so that you can quickly and easily see which pages you’ve completed and which you have not. However, since we’re a Genesis shop around here, we don’t need an extra plug-in to handle SEO – we use the built-in SEO tools the good folks at StudioPress included right in the framework.

I wanted to add these same columns to the WordPress list views for pages and posts so I whipped up this little solution. I figured I’d throw in the featured image and then remove some columns I don’t need, like author, date and comments. Add this code to your functions.php file, adjust as necessary and you’re good to go.

For Pages List View

/* SHOW GENESIS SEO DATA AND FEATURED IMAGE IN ADMIN LIST VIEW */
/* --------------------------------------------------------------------------- */
add_filter('manage_pages_columns', 'add_new_pages_columns', 5);
function add_new_pages_columns($cols) {
  $cols['new_seo_title'] = __('SEO Title');
  $cols['new_seo_desc'] = __('SEO Description');
  $cols['new_seo_keywords'] = __('SEO Keywords');
  $cols['new_post_thumb'] = __('Featured Image');
  unset($cols['author']);
  unset($cols['date']);
  unset($cols['comments']);
  return $cols;
}
add_action('manage_pages_custom_column', 'add_pages_column_data', 5, 2);
function add_pages_column_data($col, $id) {
  switch($col) {
    case'new_seo_title':
      echo htmlspecialchars(stripcslashes(get_post_meta($id,'_genesis_title',TRUE)));
      break;
    case'new_seo_desc':
      echo htmlspecialchars(stripcslashes(get_post_meta($id,'_genesis_description',TRUE)));
      break;
    case'new_seo_keywords':
      echo htmlspecialchars(stripcslashes(get_post_meta($id,'_genesis_keywords',TRUE)));
      break;
    case 'new_post_thumb':
      echo the_post_thumbnail('thumbnail');
      break;
  }
}

For Posts List View

/* SHOW GENESIS SEO DATA AND FEATURED IMAGE IN ADMIN LIST VIEW */
/* --------------------------------------------------------------------------- */
add_filter('manage_posts_columns', 'add_new_posts_columns', 5);
function add_new_posts_columns($cols) {
  $cols['new_seo_title'] = __('SEO Title');
  $cols['new_seo_desc'] = __('SEO Description');
  $cols['new_seo_keywords'] = __('SEO Keywords');
  $cols['new_post_thumb'] = __('Featured Image');
  unset($cols['author']);
  unset($cols['comments']);
  return $cols;
}
add_action('manage_posts_custom_column', 'add_posts_column_data', 5, 2);
function add_posts_column_data($col, $id) {
  switch($col) {
    case'new_seo_title':
      echo htmlspecialchars(stripcslashes(get_post_meta($id,'_genesis_title',TRUE)));
      break;
    case'new_seo_desc':
      echo htmlspecialchars(stripcslashes(get_post_meta($id,'_genesis_description',TRUE)));
      break;
    case'new_seo_keywords':
      echo htmlspecialchars(stripcslashes(get_post_meta($id,'_genesis_keywords',TRUE)));
      break;
    case 'new_post_thumb':
      echo the_post_thumbnail('thumbnail');
      break;
  }
}

Viewing latest article 4
Browse Latest Browse All 29

Trending Articles