Created
April 29, 2020 17:53
-
-
Save vfontjr/31f86f45c913ba178b757631af7bc46d to your computer and use it in GitHub Desktop.
Source code for https://victorfont.com/dry-coding-wordpress-actions-filters/
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 | |
/** | |
* This file adds the custom portfolio post type archive template to the Executive Pro Theme. | |
* | |
* @author StudioPress | |
* @package Executive Pro | |
* @subpackage Customizations | |
*/ | |
//* Force full width content layout | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); | |
//* Remove the breadcrumb navigation | |
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' ); | |
//* Remove the post info function | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 5 ); | |
//* Remove the post content | |
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); | |
//* Remove the post image | |
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); | |
//* Add portfolio body class to the head | |
add_filter( 'body_class', 'executive_add_portfolio_body_class' ); | |
function executive_add_portfolio_body_class( $classes ) { | |
$classes[] = 'executive-pro-portfolio'; | |
return $classes; | |
} | |
//* Add the featured image after post title | |
add_action( 'genesis_entry_header', 'executive_portfolio_grid' ); | |
function executive_portfolio_grid() { | |
if ( $image = genesis_get_image( 'format=url&size=portfolio' ) ) { | |
printf( '<div class="portfolio-featured-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) ); | |
} | |
} | |
//* Remove the post meta function | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
genesis(); |
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 | |
function remove_genesis_actions_for_portfolio_archive() { | |
$actions_to_remove = array( | |
'genesis_before_loop' => array( | |
'function_to_remove' => 'genesis_do_breadcrumbs', | |
), | |
'genesis_entry_header' => array( | |
'function_to_remove' => 'genesis_post_info', | |
'priority' => 5, | |
), | |
'genesis_entry_content' => array( | |
'function_to_remove' => 'genesis_do_post_content', | |
), | |
'genesis_entry_content' => array( | |
'function_to_remove' => 'genesis_do_post_image', | |
'priority' => 8, | |
), | |
'genesis_entry_footer' => array( | |
'function_to_remove' => 'genesis_post_meta', | |
), | |
); | |
foreach ( $actions_to_remove as $tag => $args ) { | |
$priority = array_key_exists( 'priority', $args ) ? $args['priority'] : 10; | |
remove_action( $tag, $args['function_to_remove'], $priority ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment