Last active
March 28, 2020 19:42
-
-
Save wpfangirl/b6f6921b22dc9daabb13496ab45c74ab to your computer and use it in GitHub Desktop.
Add Gutenberg suport and a block template to an existing portfolio post type (e.g. from the Portfolio Post Type or Genesis Portfolio Pro plugin)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds block template to existing post type 'portfolio' with taxonomies 'portfolio_category' and 'portfolio_tag'. | |
*/ | |
// Add Block Template to existing portfolio post type | |
function bbp_add_portfolio_template() { | |
$post_type_object = get_post_type_object( 'portfolio' ); | |
$post_type_object->show_in_rest = true; | |
$post_type_object->rest_base = 'portfolio'; | |
$post_type_object->template = array( | |
array( 'core/heading', array( | |
'placeholder' => 'Executive Summary', | |
'level' => '2', | |
) | |
), | |
array( 'core/paragraph', array( | |
'placeholder' => 'Put the problem and the results you got into about 160 characters, with keywords. Then you can use it for your meta description.', | |
'customFontSize' => '24', | |
) | |
), | |
array( 'core/columns', | |
array( | |
'align' => 'wide', | |
'columns' => '2', | |
), | |
array( | |
array( 'core/column', array(), array( | |
array( 'core/image', array() ), | |
) ), | |
array( 'core/column', array(), array( | |
array( 'core/heading', array( | |
'placeholder'=> 'Client Company Name', | |
'level' => '3', | |
) ), | |
array( 'core/paragraph', array( | |
'placeholder' => 'Describe your client: industry, company size, who their customer is, what they do.', | |
) ), | |
) ), | |
) ), | |
array('core/quote', array( | |
) ), | |
array( 'core/heading', array( | |
'placeholder' => 'The Challenge', | |
'level' => '2', | |
) ), | |
array( 'core/paragraph', array( | |
'placeholder' => 'Why did your client need your services?', | |
) ), | |
array( 'core/image', array( | |
'align' => 'wide', | |
) ), | |
array( 'core/heading', array( | |
'placeholder' => 'Your Solution', | |
'level' => '2', | |
) ), | |
array( 'core/paragraph', array( | |
'placeholder' => 'Write two or three short paragraphs describing what you did to solve the problem.', | |
) ), | |
array( 'core/image', array( | |
'align' => 'wide', | |
) ), | |
array( 'core/heading', array( | |
'placeholder' => 'Results and ROI', | |
'level' => '2', | |
) ), | |
array( 'core/paragraph', array( | |
'placeholder' => 'You need a keyword-rich sound bite with numbers in it, e.g. tripled revenue or cut production time in half.', | |
'customFontSize' => '20', | |
'customTextColor' => '#FF6900', | |
) ), | |
array( 'core/paragraph', array( | |
'placeholder' => 'Provide more detail about how happy the client is and why. You could put another quote here instead.', | |
) ), | |
array( 'core/image', array( | |
'align' => 'wide', | |
) ), | |
array( 'core/paragraph', array( | |
'placeholder' => 'Write your call to action here. Give it a large font size and a color background.', | |
'customFontSize' => '28', | |
'customTextColor' => '#ffffff', | |
'customBackgroundColor' => '#313131', | |
) ), | |
array( 'core/button', array( | |
'customBackgroundColor' => '#CF2E2E', | |
'customTextColor' => '#ffffff', | |
'align' => 'center', | |
) ), | |
); | |
} | |
add_action( 'init', 'bbp_add_portfolio_template' ); | |
// Add REST API support for portfolio categories | |
function add_portfolio_cat_to_api() { | |
$mytax = get_taxonomy( 'portfolio_category' ); | |
$mytax->show_in_rest = true; | |
} | |
add_action( 'init', 'add_portfolio_cat_to_api', 30 ); | |
// Add REST API support for portfolio tags | |
function add_portfolio_tag_to_api() { | |
$mytax = get_taxonomy( 'portfolio_tag' ); | |
$mytax->show_in_rest = true; | |
} | |
add_action( 'init', 'add_portfolio_tag_to_api', 30 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment