Developer Documentation - AIOSEO https://aioseo.com Tue, 19 Mar 2024 13:08:37 +0000 en-US hourly 1 https://wordpress.org/?v=6.3.1 https://aioseo.com/wp-content/uploads/2020/11/symbol-logo-lg-1.png Developer Documentation - AIOSEO https://aioseo.com 32 32 aioseo_redirects_log_skip https://aioseo.com/docs/aioseo_redirects_log_skip/?utm_source=rss&utm_medium=rss&utm_campaign=aioseo_redirects_log_skip Tue, 19 Mar 2024 13:08:36 +0000 https://aioseo.com/?post_type=documentation&p=298356 Purpose This filter can be used to skip logging redirect logging in AIOSEO Redirects. Arguments (1) Example code snippet

The post aioseo_redirects_log_skip first appeared on AIOSEO.]]>
Purpose

This filter can be used to skip logging redirect logging in AIOSEO Redirects.

Arguments (1)

  1. $skip (boolean) – Skip logging.
  2. $data (array) – The redirect data.

Example code snippet

add_filter( 'aioseo_redirects_log_skip', 'redirects_log_skip', 10, 2 );
function redirects_log_skip( $skip, $data ) {
	if ( 404 === $data['http_code'] ) {
		$skip = true;
	}

	return $skip;
}
The post aioseo_redirects_log_skip first appeared on AIOSEO.]]>
aioseo_get_post_id https://aioseo.com/docs/aioseo_get_post_id/?utm_source=rss&utm_medium=rss&utm_campaign=aioseo_get_post_id Tue, 29 Aug 2023 14:42:47 +0000 https://aioseo.com/?post_type=documentation&p=222363 Purpose This filter can be used to change the Post ID being processed by AIOSEO. Arguments (1) Example code snippet

The post aioseo_get_post_id first appeared on AIOSEO.]]>
Purpose

This filter can be used to change the Post ID being processed by AIOSEO.

Arguments (1)

  1. $postId (integer) – The Post ID.

Example code snippet

add_filter( 'aioseo_get_post_id', 'aioseo_change_post_id' );
function aioseo_change_post_id( $postId ) {
	if( is_post_type_archive( 'product' ) ) {
		$postId = 123;
	}

	return $postId;
}
The post aioseo_get_post_id first appeared on AIOSEO.]]>
aioseo_hide_version_number https://aioseo.com/docs/aioseo_hide_version_number/?utm_source=rss&utm_medium=rss&utm_campaign=aioseo_hide_version_number Tue, 09 May 2023 10:33:57 +0000 https://aioseo.com/?post_type=documentation&p=186946 Purpose This filter can be used to publicly hide the All in One SEO version number. Arguments (1) Example code snippet

The post aioseo_hide_version_number first appeared on AIOSEO.]]>
Purpose

This filter can be used to publicly hide the All in One SEO version number.

Arguments (1)

  1. $hide (boolean) – Whether to hide the version number in the frontend.

Example code snippet

add_filter( 'aioseo_hide_version_number', '__return_true' );
The post aioseo_hide_version_number first appeared on AIOSEO.]]>
Fetching & Updating AIOSEO Data via the WordPress REST API https://aioseo.com/docs/fetching-updating-aioseo-data-via-the-wordpress-rest-api/?utm_source=rss&utm_medium=rss&utm_campaign=fetching-updating-aioseo-data-via-the-wordpress-rest-api Fri, 11 Mar 2022 10:47:12 +0000 https://aioseo.com/?post_type=documentation&p=79149 The REST API addon (introduced with AIOSEO 4.1.9) is available for all Plus, Pro and Elite plan users and allows you to easily fetch and update AIOSEO data via the REST API. This can be particularly useful when you for…

The post Fetching & Updating AIOSEO Data via the WordPress REST API first appeared on AIOSEO.]]>
The REST API addon (introduced with AIOSEO 4.1.9) is available for all Plus, Pro and Elite plan users and allows you to easily fetch and update AIOSEO data via the REST API.

This can be particularly useful when you for instance have:

  • A headless WordPress site where you need to manually output your SEO data on the frontend;
  • A 3rd party system to manage your posts (e.g. eCommerce ERP with WooCommerce integration) and would like to be able to manage your SEO data via that system.

Below we’ll explain which data is available via the REST API and how you can update it.

Fetching Data

Instead of registering custom endpoints, the REST API addon integrates with the default endpoints from WordPress Core. Currently, all GET post and term routes are supported.

These include:

  • /wp/v2/posts
  • /wp/v2/pages
  • /wp/v2/media
  • /wp/v2/categories
  • /wp/v2/tags

And also all routes for custom post types and custom taxonomies on your website that have support for the REST API enabled.

The following fields will be included in the response of these routes:

aioseo_head

This field includes the raw SEO data that would normally be output by All in One SEO into the source code of your post/term as a text string.

If you have a headless WordPress website, you can output this data straight into the source code on the frontend of your installation.

aioseo_head_json

This field includes the same values of the aioseo_head data (see above), but in JSON format.

This allows you to easily filter the data before you output it into the source code or use it for another purpose.

Please note that this data does not include the HTML code for the meta tags that these values are used for, so you’ll need to construct these yourself.

aioseo_meta_data

This field includes the data that is stored into AIOSEO’s custom post and term tables in JSON format.

This data should be mainly used when you want to manipulate the existing data and then update it on your website.

Updating Data

In order to update data via the REST API, you must authenticate yourself. If you are unsure how to do this, please read the WordPress REST API documentation.

The user you’ve authenticated with must also have any of the following capabilities in order to be able to update any AIOSEO data via the REST API:

  • aioseo_page_general_settings
  • aioseo_page_social_settings
  • aioseo_page_schema_settings
  • aioseo_page_advanced_settings

Once you’ve met these requirements, you can update data via a POST/PUT request by adding the property aioseo_meta_data in the body of the request.

Inside this property, you can specify any of the keys that are included in the aioseo_meta_data field (see above), along with the new value.

Below is an example of how this looks like:

{
	"aioseo_meta_data": {
		"title":"NEW TITLE",
		"description":"NEW DESCRIPTION"
	}
}

If you have any particular questions about the REST API, please feel free to reach out to our support team. We will be more than happy to help you.

The post Fetching & Updating AIOSEO Data via the WordPress REST API first appeared on AIOSEO.]]>
Localizing AIOSEO Data via the Translations API https://aioseo.com/docs/localizing-aioseo-data-via-the-translations-api/?utm_source=rss&utm_medium=rss&utm_campaign=localizing-aioseo-data-via-the-translations-api Wed, 15 Jun 2022 15:20:13 +0000 https://aioseo.com/?post_type=documentation&p=98532 In All in One SEO 4.2.2 we introduced a number of filter hooks that make it easier for multilingual plugin developers to integrate with our plugin. Common uses for these filter hooks are: Localizing the post/term meta AIOSEO outputs in…

The post Localizing AIOSEO Data via the Translations API first appeared on AIOSEO.]]>
In All in One SEO 4.2.2 we introduced a number of filter hooks that make it easier for multilingual plugin developers to integrate with our plugin.

Common uses for these filter hooks are:

  • Localizing the post/term meta AIOSEO outputs in the source code
  • Integrating with the multilingual sitemap capabilities of AIOSEO
  • Localizing the options of AIOSEO (e.g. default title/description formats)

Localizing Post/Term Meta

One of the core functionalities of All in One SEO is outputting SEO data, social markup and JSON schema into the source code of every page.

AIOSEO stores this data in its own custom tables, aioseo_posts and aioseo_terms. As a result, this data cannot be accessed like traditional post/term meta.

Filtering Data When it is Loaded

When this data is loaded, it can be filtered using the aioseo_get_post and aioseo_get_term hooks.

The data is typically only loaded once per request and should stay consistent for the duration of the request.

Filtering Data When it is Saved

If needed, the data can also be filtered before it is saved by using the aioseo_save_post and aioseo_save_term hooks.

Please note the following:

  • If a post is saved via the Block Editor, then this hook will run twice. Once when the post is saved via the REST API by the Block Editor; another time when the post is saved via a regular POST request.
  • AIOSEO should automatically sanitize any of the data you’ve filtered, but we still implore you to adequately sanitize any data you manipulate on your end as well.

Integrating with the multilingual sitemap

All in One SEO is capable of generating a multilingual sitemap if you tell it what the translated versions of each post/term are. You can add dynamically add this information using our aioseo_sitemap_post and aioseo_sitemap_term hooks respectively.

Supported Plugins

The following multilingual plugins have been confirmed as compatible with AIOSEO:

  • WPML

These plugins may support AIOSEO, but have not been confirmed yet:

  • TranslatePress
  • Polylang
  • Weglot
  • MultilingualPress
  • qTranslate-XT
  • WPGlobus

Don’t see a plugin on this list or does your multilingual plugin not support AIOSEO yet? Then please reach out to the developer of the plugin and ask them to add support. You can refer them to this page for technical information on our filter hooks.

Are you a developer and do you need help to integrate your plugin with All in One SEO? Send us a message via our Basic Question form and we will be in touch with you shortly.

The post Localizing AIOSEO Data via the Translations API first appeared on AIOSEO.]]>
Outputting AIOSEO’s data in the HEAD without using wp_head() https://aioseo.com/docs/outputting-aioseos-data-in-the-head-without-using-wp_head/?utm_source=rss&utm_medium=rss&utm_campaign=outputting-aioseos-data-in-the-head-without-using-wp_head Mon, 27 Jun 2022 11:07:58 +0000 https://aioseo.com/?post_type=documentation&p=101250 To output the SEO data, social meta and JSON schema that AIOSEO generates in the HEAD section of a page without using wp_head() (in a custom theme for example), use the code snippet below: if desired, you can control which…

The post Outputting AIOSEO’s data in the HEAD without using wp_head() first appeared on AIOSEO.]]>
To output the SEO data, social meta and JSON schema that AIOSEO generates in the HEAD section of a page without using wp_head() (in a custom theme for example), use the code snippet below:

if ( function_exists( 'aioseo' ) ) {
	aioseo()->head->output();
}

if desired, you can control which sections of data are output using the aioseo_meta_views filter hook.

The post Outputting AIOSEO’s data in the HEAD without using wp_head() first appeared on AIOSEO.]]>
Removing Published Date from Article Schema https://aioseo.com/docs/removing-published-date-from-article-schema/?utm_source=rss&utm_medium=rss&utm_campaign=removing-published-date-from-article-schema Tue, 05 Jul 2022 17:32:46 +0000 https://aioseo.com/?post_type=documentation&p=103415 In some cases, search engines like Google may display the publish date of your articles in their search results. If you’d like to prevent search engines from displaying the publish date, you can use the code snippet below to remove…

The post Removing Published Date from Article Schema first appeared on AIOSEO.]]>
In some cases, search engines like Google may display the publish date of your articles in their search results. If you’d like to prevent search engines from displaying the publish date, you can use the code snippet below to remove it from the JSON schema that AIOSEO outputs.

add_filter( 'aioseo_schema_output', 'aioseo_filter_schema_output' );

function aioseo_filter_schema_output( $schema ) {
	foreach ( $schema as $index => $graphData ) {
		if ( empty( $graphData['@type'] ) ) {
			continue;
		}

		$type = strtolower( $graphData['@type'] );
		switch ( $type ) {
			case 'article':
			case 'blogposting':
			case 'newsarticle':
				unset( $schema[ $index ]['datePublished'] );
				unset( $schema[ $index ]['dateModified'] );
				break;
			default:
				break;
		}
	}

	return $schema;
}
The post Removing Published Date from Article Schema first appeared on AIOSEO.]]>
aioseo_access_control_excluded_roles https://aioseo.com/docs/aioseo_access_control_excluded_roles/?utm_source=rss&utm_medium=rss&utm_campaign=aioseo_access_control_excluded_roles Tue, 24 Aug 2021 16:47:00 +0000 https://aioseo.com/?post_type=documentation&p=49268 Purpose & version added This filter can be used to manage the excluded roles from Access Control. Arguments (1) $roles (array) – A list of roles being ignored. Example code snippet The code snippet below is just an example of…

The post aioseo_access_control_excluded_roles first appeared on AIOSEO.]]>
Purpose & version added

This filter can be used to manage the excluded roles from Access Control.

Arguments (1)

  1. $roles (array) – A list of roles being ignored.

Example code snippet

The code snippet below is just an example of how this filter can be used. In the example below, we’ll remove the customer role from the excluded roles.

// Removes the customer role from the exclusion list.
add_filter( 'aioseo_access_control_excluded_roles', 'aioseo_filter_access_control_excluded_roles' );
function aioseo_filter_access_control_excluded_roles( $roles ) {
	if ( ( $key = array_search( 'customer', $roles ) ) !== false ) {
		unset( $roles[ $key ] );
	}
	return $roles;
}

Changelog

VersionDescription
4.1.4Introduced.
The post aioseo_access_control_excluded_roles first appeared on AIOSEO.]]>
aioseo_breadcrumbs_link_current_item https://aioseo.com/docs/aioseo_breadcrumbs_link_current_item/?utm_source=rss&utm_medium=rss&utm_campaign=aioseo_breadcrumbs_link_current_item Tue, 27 Jul 2021 20:42:52 +0000 https://aioseo.com/?post_type=documentation&p=48232 Purpose This filter can be used to add or remove the link from the current item in the breadcrumb trail. Arguments (1) $linkCurrentItem (boolean) – Keep or remove the link. Example code snippet The code snippet below is just an…

The post aioseo_breadcrumbs_link_current_item first appeared on AIOSEO.]]>
Purpose

This filter can be used to add or remove the link from the current item in the breadcrumb trail.

Arguments (1)

  1. $linkCurrentItem (boolean) – Keep or remove the link.

Example code snippet

The code snippet below is just an example of how this filter can be used. In the example below we’ll remove the link from the current breadcrumb item if we’re on a page.

// Removes the link of the last crumb if it's a page.
add_filter( 'aioseo_breadcrumbs_link_current_item', 'aioseo_breadcrumbs_link_current_item', 10 );
function aioseo_breadcrumbs_link_current_item( $linkCurrentItem ) {
	if ( is_singular( 'page' ) ) {
		$linkCurrentItem = false;
	}

	return $linkCurrentItem;
}

The post aioseo_breadcrumbs_link_current_item first appeared on AIOSEO.]]>
aioseo_breadcrumbs_output https://aioseo.com/docs/aioseo_breadcrumbs_output/?utm_source=rss&utm_medium=rss&utm_campaign=aioseo_breadcrumbs_output Tue, 27 Jul 2021 20:40:29 +0000 https://aioseo.com/?post_type=documentation&p=48219 Purpose This filter can be used to control the display of breadcrumbs (show or hide). Arguments (1) $display (boolean) – Show or hide. Example code snippet The code snippet below is just an example of how this filter can be…

The post aioseo_breadcrumbs_output first appeared on AIOSEO.]]>
Purpose

This filter can be used to control the display of breadcrumbs (show or hide).

Arguments (1)

  1. $display (boolean) – Show or hide.

Example code snippet

The code snippet below is just an example of how this filter can be used. In the example below we’ll hide the breadcrumbs on pages.

// Hide breadcrumbs on pages.
add_filter( 'aioseo_breadcrumbs_output', 'aioseo_breadcrumbs_output' );
function aioseo_breadcrumbs_output( $display ) {
	if ( is_singular( 'page' ) ) {
		$display = false;
	}

	return $display;
}

The post aioseo_breadcrumbs_output first appeared on AIOSEO.]]>