This file contains 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 video post type archive template to a Genesis child theme. | |
* | |
*/ | |
//* Load Isotope | |
wp_enqueue_script('isotope', get_stylesheet_directory_uri() . '/js/jquery.isotope.min.js', array('jquery'), '', true); | |
wp_enqueue_script('isotope_init', get_stylesheet_directory_uri() . '/js/isotope_init.js', array('isotope'), '1.0.0', true); |
This file contains 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
//* Add login or logout to menu | |
add_filter( 'wp_nav_menu_items', 'sp_add_loginout_link', 10, 2 ); | |
function sp_add_loginout_link( $items, $args ) { | |
// Change 'primary' to 'secondary' to put the login link in your secondary nav bar | |
if ( $args->theme_location != 'primary' ) | |
return $items; | |
if ( is_user_logged_in() ) { | |
$items .= '<li class="menu-item right"><a href="'. wp_logout_url() .'">Log Out</a></li>'; | |
} else { |
This file contains 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
//* Get post view counts | |
function getPostViews($postID){ | |
$count_key = 'post_views_count'; | |
$count = get_post_meta($postID, $count_key, true); | |
if($count==''){ | |
delete_post_meta($postID, $count_key); | |
add_post_meta($postID, $count_key, '0'); | |
return "0 Views"; | |
} | |
return $count.' Views'; |
This file contains 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
//* Redirect posts to original URL | |
add_action( 'template_redirect', 'nabm_original_post_redirect' ); | |
function nabm_original_post_redirect() { | |
if ( ! is_singular() ) { | |
return; | |
} | |
if ( $url = genesis_get_custom_field( 'rss_pi_source_url' ) ) { | |
wp_redirect( esc_url_raw( $url ), 301 ); | |
exit; | |
} |
This file contains 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
//* Open post title links in new tab | |
function nabm_filter_entry_title() { | |
function nabm_post_title_output( $title ) { | |
$title = sprintf( '<h1 class="entry-title" itemprop="headline"><a target="_blank" href="%s" title="%s">%s</a></h1>', get_permalink(), the_title_attribute( 'echo=0' ), get_the_title() ); | |
return $title; | |
} | |
add_filter( 'genesis_post_title_output', 'nabm_post_title_output', 15 ); | |
} | |
add_action('genesis_header', 'nabm_filter_entry_title'); |
This file contains 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
//* Show 12 posts per page | |
add_action( 'pre_get_posts', 'nabm_change_posts_per_page' ); | |
function nabm_change_posts_per_page( $query ) { | |
if ( ! $query->is_main_query() || is_admin() || is_feed() ) { | |
return $query; | |
} | |
if ( is_front_page() ) { | |
$query->set( 'posts_per_page', 12 ); | |
} | |
return $query; |
OlderNewer