Quantcast
Channel: Docs - AIOSEO
Viewing all 404 articles
Browse latest View live

Filter the description used in Schema markup

$
0
0

By default, All in One SEO Pack uses the SEO Description for the description in Schema markup on Posts and Pages.  If there’s no SEO Description then we will use the Post Excerpt.

This filter can be used to change this behavior to use the Post Excerpt or Post Content (instead of the SEO Description):

function aioseop_modify_schema_description( $data ) {
     global $post;
     if ( ! empty( $post->post_excerpt ) ) {
          $post_description = $post->post_excerpt;  // Use the post excerpt if one exists
     } else {
          $post_description = $post->post_content;  // Use the post content if there's no post excerpt
     }
     $data['description'] = $post_description;

     return $data;
}
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_WebPage', 'aioseop_modify_schema_description' );
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_Article', 'aioseop_modify_schema_description' );

You can use WordPress Conditional Tags if you want to control whether this is only used for Pages or only for Posts.

For instructions on how to use this code, please refer to our FAQ here.


Filter XML Sitemap data

$
0
0

The All in One SEO Pack aiosp_sitemap_data filter hook.

Description

$sitemap_data = apply_filters( 'aiosp_sitemap_data', $sitemap_data, $sitemap_type, $page_number, $aioseop_options );

This filter can be used to filter the data in your XML sitemap.


Parameters (4)

0.$sitemap_data (array)
contains all sitemap data for the current sitemap file/page.
1.$sitemap_type (string)
indicates the type of the sitemap (e.g. root, posts, pages, rss, etc.).
2.$page_number (int)
the current page number (only relevant when Sitemap Indexes is enabled).
3.$aioseop_options (array)
user-defined plugin settings.

Defined (4)

The filter is defined in the following location(s).

pro/aioseop_google_tag_manager.php (4 occurrences)

For instructions on how to use this code, please refer to our FAQ here.

Filter image in Schema.org

$
0
0

By default, All in One SEO Pack uses the Featured Image for a post or page as the image in the Schema.org markup.  This filter can be used to change the image for a specific post ID.

function aioseop_schema_custom_image( $data ) {
     global $post;

     if( $post->ID === 1 ) {

          $image_data = array(
          '@type' => 'ImageObject',
          'url' => 'https://mydomain.com/wp-content/uploads/2019/09/image.jpg', //Absolute or relative URL can be used
          'width' => 300, // Optional
          'height' => 300, // Optional
          'caption' => 'Image caption', // Optional
          );

          $data['image'] = $image_data;

     }

     return $data;
}

// Filter for WebPage schema type
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_WebPage', 'aioseop_schema_custom_image' );

//Filter for Article schema type 
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_Article', 'aioseop_schema_custom_image' );

 

For instructions on how to use this code, please refer to our FAQ here.

Filter description in Schema.org

$
0
0

By default, All in One SEO Pack uses the SEO Description for a post or page as the description in the Schema.org markup.  This filter can be used to change this to the post excerpt or post/page content for all content, all content in a post type, or for a specific post ID.

function aioseop_schema_custom_description( $data ) {
     global $post;

     if( $post->ID === 1 ) {

          // Use post_excerpt below for the excerpt
          $description = $post->post_content; 

          $data['description'] = $description;
     }
     return $data;

}

// Filter for WebPage schema type
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_WebPage', 'aioseop_schema_custom_description' );

//Filter for Article schema type
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_Article', 'aioseop_schema_custom_description' );

 

For instructions on how to use this code, please refer to our FAQ here.

Filter social profiles in Schema.org

$
0
0

By default, All in One SEO Pack only has fields for Facebook and Twitter profiles on the Edit User screen.  This filter can be used to add more social profiles for output in our Schema.org markup for Author on Posts.

function aioseop_schema_add_social_profiles( $data ) {
     if ( is_single() ) {
          global $post;
          $post_author_nicename = get_the_author_meta( 'user_nicename', $post->post_author );

          $users_social = array(
               // Replace nicename with the user's nicename.
              'nicename' => array(
                   // Replace with user's social profile links adding lines for each social network.
                   'https://www.linkedin.com/in/myprofile',
                   'https://www.instagram.com/myprofile',
              ),
          );

          // This will add the social profile links to a matched user.
          if ( isset( $users_social[ $post_author_nicename ] ) ) {
               $data['sameAs'] = array_merge( $data['sameAs'], $users_social[ $post_author_nicename ] );
          }
     }

     return $data;
}
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_Person', 'aioseop_schema_add_social_profiles' );

For instructions on how to use this code, please refer to our FAQ here.

Disable Schema markup

$
0
0

All in One SEO Pack outputs Schema markup on all posts, pages, categories, tags and search results  when Use Schema.org Markup is enabled.  You can remove this markup for specific post types, taxonomies, etc by using the filter below:

add_filter( 'aioseop_disable_schema', 'disable_aioseop_schema' );

function disable_aioseop_schema() {
     if ( is_category() ) {  // Targets all categories
          return true;
     }
}

Filter added in All in One SEO Pack v3.3.

For instructions on how to use this code, please refer to our FAQ here.

Google Tag Manager

$
0
0

In version 3.3 of All in One SEO Pack Pro, we introduced support for Google Tag Manager.  You can find this new option under All in One SEO > General Settings > Google Analytics as shown below:

Google Analytics box in All in One SEO Pack

Enter your GTM Container ID in the field and All in One SEO Pack Pro will output the Google Tag Manager code on every page of your site.  It will also hide some of the Google Analytics advanced features that are replaced by Google Tag Manager.

If you would like to use multiple Google Tag Manager Container IDs on your website, then you do so using this filter hook.

This feature is in All in One SEO Pack Pro only.  Upgrade to the Pro plugin to take advantage of this feature.

What are media attachments and should I submit them to search engines?

$
0
0

We often get asked about whether to include media attachments in the XML Sitemap or whether to set them to NOINDEX.  This FAQ will address questions related to media attachments and how they affect your site SEO.

What is a media attachment?

A media Attachment Page is a post type that is built into WordPress.  It is a singular page that displays a media item, such as an image, along with some additional information.

When you add a media item to your content, you have the option to link the media item to its Attachment Page as shown in the screenshots below:

When a visitor clicks on the image, they are taken to the Attachment Page which displays the image title, the image, a caption and/or description (if set), and the comments form (if comments are enabled).

How would I use Attachment Pages?

Because an Attachment Page is a standard WordPress post type, it has a theme template file that allows you to control what content is displayed and how the page is styled.

A good example of this would be a photography theme that uses the Attachment Page to display EXIF data for the photo such as the make and model of the camera, and the camera settings (ISO, Exposure, Shutter Speed, etc).  It could also display geographical information of where the photo was taken.

What are the SEO benefits?

For most sites there are no SEO benefits from a media Attachment Page.  This is because these pages have little to no content on them, they just show the image title, the image itself and that’s all.  Why would a visitor want to visit or search for this page?  Answer: they wouldn’t!

However, some sites will use the media Attachment Page to display rich content about the image, such as our example above of a photography site.  In this case, you probably want visitors to be able to find this content in search engines.  The rich content on these pages could be valuable for your ability to rank for specific terms and therefore there is great benefit in terms of your overall site SEO.

What should I do?

If your media Attachment Pages contain no rich content, then you should set them to NOINDEX by going to All in One SEO > General Settings > Noindex Settings and check the box for Media / Attachments in the Default to NOINDEX setting.  You should then go to All in One SEO > XML Sitemap and uncheck the box for Media / Attachments in the Post Types setting.  This will ensure that these pages are not submitted to search engines and that search engines are instructed not to index them.

However, if your media Attachment Pages contain rich content that visitors would want to find in search engines, then you should make sure that Media / Attachments are included in your XML Sitemap and that they are not set to NOINDEX.

You should then go to All in One SEO > General Settings > Content Type Settings and ensure that Media / Attachments is checked in the SEO on only these Content Types settings.  You should then to go the Media Library and set a unique SEO Title and SEO Description for each image in the All in One SEO Pack section.

Won’t this affect indexing of my images?

No, this has no affect on images.  This only affects media Attachment Pages.

Images will still be included in the XML Sitemap provided you don’t check the Exclude Images setting.

Images will still be indexed provided the search engine feels that there’s a benefit to including your images in their image search results.  Search engines such as Google may not index any or all of your images, so don’t be surprised if your images don’t appear in their image search.


How do I get Google to show sitelinks for my site?

$
0
0

We are often asked how to get Google to show that structured result that looks like this:

Google Sitelinks search results

The short answer is that you can’t make Google display search results like this.  It happens on a per search basis depending on whether they feel it’s the best way to display the results.  Their official answer is “We only show sitelinks for results when we think they’ll be useful to the user.”

However, there are some things you can do to help Google, these are:

  • Implement good page structure
  • Make sure your navigation menu matches your page structure
  • Use breadcrumbs
  • Set good anchor text on your internal links to important pages

You can read more about this on Google’s Search Console Help page here.

Using a different CDN for script enqueuing

$
0
0

Some features in All in One SEO Pack require us to enqueue external dependencies through CDNs. You can dynamically filter the CDNs we rely on through the script_loader_src filter. Below you can find a demo code snippet that shows you how to use this filter. This can be useful if you’re operating from a country where certain CDNs are blocked.

 

add_filter( 'script_loader_src', 'aioseop_change_cdn_provider' );

function aioseop_change_cdn_provider( string $src ) {

   if( ! is_admin() ) {
      return;
   }

   if( preg_match('/.*cdn.jsdelivr.net.*/', $src ) ) {
      $src = 'https://cdnjs.cloudflare.com/ajax/libs/xregexp/3.2.0/xregexp-all.min.js';
   }


return $src;
}

aioseop_video_sitemap_scan_posts_limit

$
0
0

The aioseop_video_sitemap_scan_posts_limit filter hook.

Description

$scan_posts_limit = apply_filters( 'aioseop_video_sitemap_scan_posts_limit', 20 );

This filter can be used to change the amount of posts that are scanned for videos during each partial scan of the Video Sitemap module.

The default amount of posts per scan is 20. If you were to increase the amount of posts per partial scan, the Video Sitemap would be able to generate your video sitemap more quickly (useful for large sites with thousands of posts), but this is at the risk of your site’s performance and stability. The same applies vice versa.


Parameters (1)

0. (int)
the amount of posts that are scanned for videos during each partial scan.

Usage

The code example below can be used to change the amount of posts:

add_filter( 'aioseop_video_sitemap_scan_posts_limit', 'change_posts_limit' );

function change_posts_limit( $amount_of_posts ) {
        $amount_of_posts = 100;
        return $amount_of_posts;
}

Defined (1)

The filter is defined in the following location(s).

pro/video_sitemap.php (1 occurrence)

Supported PHP Versions for All in One SEO

$
0
0

If you were linked to this page from your WordPress dashboard, then it means that you’re running an outdated version of PHP.

PHP is the programming language that WordPress and All in One SEO are built on. The version that is currently used for your site is either insecure or no longer supported.

Newer versions of PHP are both faster and more secure. In fact, the version of PHP your website is using no longer receives security updates, which is why we sent you the notice.

The easiest way to resolve this issue is to contact your web hosting provider and ask them to update the PHP version on your hosting account. This actually is quite easy, and something they should be doing proactively. However if your web hosting company is unwilling to do this, then it clearly shows that they DO NOT care about your website security.

In that case, we recommend that you switch to one of the recommended WordPress hosting companies listed on WPBeginner’s article.

At All in One SEO, our favorites are Bluehost and SiteGround, both of them are officially recommended by WordPress as well. Our website is hosted with SiteGround.

Although you should have your web hosting company update your PHP version 7.3 or greater, All in One SEO currently works on any PHP version 5.2.4 or higher (WordPress itself requires PHP 5.6+ for the latest updates).

Support for PHP 5.2 will be discontinued in 2020.
Support for PHP 5.3 will be discontinued in 2020.
Support for PHP 5.4 will be discontinued in 2020.
Support for PHP 5.5 will be discontinued in 2020.

Filtering the title attribute of an image

$
0
0

The aioseop_image_seo_title filter hook.

Description

$title = apply_filters( 'aioseop_image_seo_title', $this->get_attribute( 'title', $image_id ), $image_id );

This filter can be used to filter the title attribute of images.


Parameters (2)

0. $value (string)
the value of the title attribute.
1. $image_id (int)
the ID of the image.

Usage

The code example below can be used to change the title attribute for a given post with ID 1:

add_filter( 'aioseop_image_seo_title', 'my_change_image_title', 10, 2 );

function my_change_image_title( $value, $image_id ) {
	if( 1 === $image_id ) {
		return 'This is the filtered title attribute.';
	}
	return $value;
}

Defined (1)

The filter is defined in the following location(s).

pro/class-aioseop-image-seo.php (2 occurrences)

For instructions on how to use this code, please refer to our FAQ here.

Filtering the alt tag attribute of an image

$
0
0

The aioseop_image_seo_alt_tag filter hook.

Description

$alt_tag = apply_filters( 'aioseop_image_seo_alt_tag', $this->get_attribute( 'alt', $image_id ), $image_id );

This filter can be used to filter the alt tag attribute of images.


Parameters (2)

0. $value (string)
the value of the alt tag attribute.
1. $image_id (int)
the ID of the image.

Usage

The code example below can be used to change the alt tag attribute for a given post with ID 1:

add_filter( 'aioseop_image_seo_alt_tag', 'my_change_image_alt_tag', 10, 2 );

function my_change_image_alt_tag( $value, $image_id ) {
if( 1 === $image_id ) {
return 'This is the filtered alt tag attribute.';
}
return $value;
}

Defined (1)

The filter is defined in the following location(s).

pro/class-aioseop-image-seo.php (2 occurrences)

For instructions on how to use this code, please refer to our FAQ here.

Disabling our Image SEO columns in the Media Library

$
0
0

The aioseop_image_seo_media_columns filter hook.

Description

This filter can be used to disable the extra columns that are added by the Image SEO module in the Media Library.


Parameters (1)

0. (boolean)
whether or not the columns should be added.

Usage

The code example below can be used to disable the columns:

add_filter( 'aioseop_image_attribute_columns', 'my_disable_media_columns' );

function my_disable_media_columns( $value ) {
        return false;
}

Defined (1)

The filter is defined in the following location(s).

pro/class-aioseop-image-seo.php (1 occurrence)

For instructions on how to use this code, please refer to our FAQ here.


Image SEO Module

$
0
0

Available to customers on the Business License and above

Image SEO module in All in One SEO Pack Pro

Image SEO module in All in One SEO Pro

The Image SEO module is a premium feature that enables you to globally control the Title Attribute and Alt Text for attachment pages and images that are embedded in your content.  These can be set based on a specified format, similar to the Title Format settings in the General Settings menu.

Below are the options in the Image SEO module:

Title Attribute Format

This field enables you to set how your image Title Attributes will be generated by All in One SEO.

For example, you may want all your Image Title Attributes to include your Post Title followed by your Site Title.  In this case, you can use the appropriate macros from the list below in the Title Attribute Format field.

Here is the list of supported macros you can use:

  • %image_title%
         The title of your image as shown in the Media Library
  • %site_title%
         Your site title as shown under Settings > General > Site Title
  • %site_description%
         Your site description as shown under Settings > General > Tagline
  • %image_seo_title%
         The SEO title set for your image in the Media Library
  • %image_seo_description%
         The SEO description set for your image in the Media Library
  • %post_seo_title%
         The SEO title set for your post or page
  • %post_seo_description%
         The SEO description set for your post or page
  • %alt_tag%
         The Alt Text for your image as shown in the Media Library
  • %post_title%
         The title of the post or page
  • %category_title%
         The name/title of your category
  • %post_date%
         The date when the image was published (localized)
  • %post_year%
         The year when the image was published (localized)
  • %post_month%
         The month when the image was published (localized)
  • %tax_product_cat%
         The title of your WooCommerce Product Category
  • %tax_product_tag%
         The title of your WooCommerce Product Tag

Any of the macros above can be used in combination with each other or with your own text.

Strip Punctuation For Title Attributes

This option will strip all punctuation marks such as commas, periods, semicolons, etc. from the Title Attributes that All in One SEO generates for your images. This also applies to non-Latin languages such as Chinese, Japanese, Hindi, etc.

Alt Tag Attribute Format

This field works the same way as the Title Attribute Format field above.  It enables you to set how your image Alt Text will be created by All in One SEO.  The same macros (see above) can be used in this field.

Strip Punctuation For Alt Tag Attributes

This option will strip all punctuation marks such as commas, periods, semicolons, etc. from the Alt Text that All in One SEO generates for your images. This also applies to non-Latin languages such as Chinese, Japanese, Hindi, etc.

Image Sitemap

The XML Sitemap module in All in One SEO includes an Image Sitemap by default.  Images in your content are automatically included in the XML Sitemap and are submitted to Google, Bing and other search engines.  If you wish to disable this feature, you can do so by enabling the Exclude Images setting.

Further Reading

For more information about how Image Alt Text and Title Attributes can improve your on-site SEO, please read this WP Beginner article on Image Alt Text vs Image Title.

Adding nofollow, sponsored and title attributes to links

$
0
0

All in One SEO enables you to control important information about your internal and external links in your content, that will help with your SEO.  These include:

  • The link title attribute (Classic Editor only)
  • The nofollow attribute
  • The sponsored attribute

Here’s how to control these:

Classic Editor

Select your text and click the Insert Link button in the button bar as you would normally.  Click the Link Options icon

You’ll see the Title field and you’ll see checkboxes for Add rel=”nofollow” to link and Add rel=”sponsored” to link as shown below:

Gutenberg Block Editor

Select your text and click the Add Link button as you would normally.  Click the Link Settings down arrow and you’ll see toggles for Add “nofollow” to link and Add “sponsored” to link as shown below:

 

The value of these to your onsite SEO is explained below:

  • The link title attribute tells search engines about the content you’re linking to.  You should use it to provide a brief description or where you’re linking to.  Don’t stuff this with keywords.  This has a negligible value in modern SEO.
  • The nofollow attribute tells search engines not to follow this link.  You’d use this mainly for external links where the external content provides no benefit in SEO value to your site.  Each time you link to an external site, you give them a little of your SEO value.
  • The sponsored attribute should be used for links that were created as part of advertisements, sponsorships or other compensation agreements.  You’d use this mainly for external links.

aisop_woocommerce_hide_hidden_products

$
0
0
The All In One SEO Pack aisop woocommerce hide hidden products hook.

Description

apply_filters( aisop_woocommerce_hide_hidden_products, true );

Parameters (0)

N/A


Usage

You can use this filter hook as in the following example:
add_filter( 'aisop_woocommerce_hide_hidden_products', '__return_false' );

Defined (1)

The filter is defined in the following location(s).

/pro/functions_class.php

For instructions on how to use this code, please refer to our FAQ here.

Excluding Posts from the sitemap

$
0
0

The aioseop_sitemap_post_filter filter hook.

Description

apply_filters( 'aioseop_sitemap_post_filter', $posts, $args );

This filter can be used to filter the posts that are included in the sitemap.


Parameters (1)

0. $posts (array)
the posts that are included in the current sitemap.
1. $args(array)
additional context info, such as the post type.

Usage

The code example below can be used to exclude posts with a given ID from the sitemap:

add_filter( 'aiosp_sitemap_post_filter', 'exclude_posts_from_sitemap', 10, 2 );

function exclude_posts_from_sitemap( $posts, $args ) {
	$excluded_post_ids = array( '16', '22', '82');

	$filtered_posts = array();
	foreach( $posts as $post) {
		if( ! in_array($post->ID, $excluded_post_ids)) {
			array_push($filtered_posts, $post);
		}
	}
	return $filtered_posts;
}

For instructions on how to use this code, please refer to our FAQ here.

Disable BreadcrumbList Schema

$
0
0

All in One SEO v3.4 added Schema.org structured data markup for Breadcrumbs (https://developers.google.com/search/docs/data-types/breadcrumb).  Some users may wish to disable this if their theme or another plugin already outputs this Schema markup.

The filter code below will disable only the BreadcrumbList Schema markup:

function prefix_schema_remove_breadcrumb( $layout ) {
     $array_key = array_search( '[aioseop_schema_BreadcrumbList]', $layout['@graph'] );
     if ( $array_key ) {
          unset( $layout['@graph'][ $array_key ] );
          $graphs_types = array(
               'WebPage',
               'CollectionPage',
               'SearchResultsPage',
               'ProfilePage',
          );
          foreach ( $graphs_types as $graphs_type ) {
               add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_' . $graphs_type, function ( $data ) {
                    if ( $data['breadcrumb'] ) {
                         unset( $data['breadcrumb'] );
                    }
                    return $data;
               });
          }
     }
     return $layout;
}

add_filter( 'aioseop_schema_layout', 'prefix_schema_remove_breadcrumb' );

For instructions on how to use this code, please refer to our FAQ here.

Viewing all 404 articles
Browse latest View live