Skip to content

Instantly share code, notes, and snippets.

@lucien144
Last active June 16, 2021 12:01
Show Gist options
  • Save lucien144/c0a90813ffa4eccdefdda4413e5bb56e to your computer and use it in GitHub Desktop.
Save lucien144/c0a90813ffa4eccdefdda4413e5bb56e to your computer and use it in GitHub Desktop.
Wordpress ACF for custom SEO
<?php
// Mandatory ACF plugin: https://wordpress.org/plugins/acf-code-field/
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_5b9a038a203dd',
'title' => 'SEO Settings',
'fields' => array(
array(
'key' => 'field_5b9a065e30df8',
'label' => 'Meta',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array(
'key' => 'field_5b9a03d20ec54',
'label' => 'Title',
'name' => 'seo_title',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5b9a03f30ec55',
'label' => 'Description',
'name' => 'seo_description',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => '',
),
array(
'key' => 'field_5b9a03fd0ec56',
'label' => 'Keywords',
'name' => 'seo_keywords',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5b9a048055f99',
'label' => 'Robots',
'name' => 'seo_robots',
'type' => 'button_group',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'index' => 'Index',
'noindex' => 'No index',
),
'allow_null' => 0,
'default_value' => '',
'layout' => 'horizontal',
'return_format' => 'value',
),
array(
'key' => 'field_5b9a04c855f9a',
'label' => 'Follow',
'name' => 'seo_follow',
'type' => 'button_group',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'follow' => 'Follow',
'nofollow' => 'Nofollow',
),
'allow_null' => 0,
'default_value' => '',
'layout' => 'horizontal',
'return_format' => 'value',
),
array(
'key' => 'field_5b9a050155f9b',
'label' => 'Canonical URL',
'name' => 'seo_canonical',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5bbbfa2aaf9b2',
'label' => 'Redirect 301',
'name' => 'seo_redirect',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5b9a066d30df9',
'label' => 'FB',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array(
'key' => 'field_5b9a05c745d54',
'label' => 'Title',
'name' => 'facebook_title',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5b9a05f545d55',
'label' => 'Description',
'name' => 'facebook_description',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => '',
),
array(
'key' => 'field_5b9a060245d56',
'label' => 'Image',
'name' => 'facebook_image',
'type' => 'image',
'instructions' => 'Recommended size: 1200x630',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'array',
'preview_size' => 'thumbnail',
'library' => 'all',
'min_width' => 1200,
'min_height' => 630,
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => 'jpg',
),
array(
'key' => 'field_5b9a06fe55671',
'label' => 'TW',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array(
'key' => 'field_5b9a072655672',
'label' => 'Title',
'name' => 'twitter_title',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_5b9a072f55673',
'label' => 'Description',
'name' => 'twitter_description',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => '',
),
array(
'key' => 'field_5b9a073955674',
'label' => 'Image',
'name' => 'twitter_image',
'type' => 'image',
'instructions' => 'Recommended size: 1024x512',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'array',
'preview_size' => 'thumbnail',
'library' => 'all',
'min_width' => 1024,
'min_height' => 512,
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => 'jpg',
),
array(
'key' => 'field_5b9a076aec2da',
'label' => 'Scripts',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array(
'key' => 'field_5b9a077fec2db',
'label' => 'Before closing /HEAD tag',
'name' => 'scripts__before_head',
'type' => 'acf_code_field',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'mode' => 'htmlmixed',
'theme' => 'monokai',
),
array(
'key' => 'field_5b9a0794ec2dc',
'label' => 'After opening BODY tag',
'name' => 'scripts__after_body',
'type' => 'acf_code_field',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'mode' => 'htmlmixed',
'theme' => 'monokai',
),
array(
'key' => 'field_5b9a07a8ec2dd',
'label' => 'Before closing /BODY tag',
'name' => 'scripts__before_body',
'type' => 'acf_code_field',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'mode' => 'htmlmixed',
'theme' => 'monokai',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '!=',
'value' => 'unknown',
),
),
),
'menu_order' => 0,
'position' => 'side',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
));
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment