Advertisement
srikat

Untitled

Jan 9th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.48 KB | None | 0 0
  1. //* Make Font Awesome available
  2. add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
  3. function enqueue_font_awesome() {
  4.  
  5.     wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css' );
  6.  
  7. }
  8.  
  9. add_action( 'wp_enqueue_scripts', 'sk_sitewide_non_handhelds_scripts' );
  10. /**
  11.  * Load js file having the code for pushing the prev/next links off screen and animating on hover.
  12.  *
  13.  * Context: Single Posts and 'movies' CPT's single entries, on desktops only.
  14.  *
  15.  * @author Sridhar Katakam
  16.  * @link   http://sridharkatakam.com/
  17.  */
  18. function sk_sitewide_non_handhelds_scripts() {
  19.  
  20.     if ( is_singular( array( 'post', 'movies' ) ) && ! wp_is_mobile() ) {
  21.         wp_enqueue_script( 'sitewide-non-handhelds',  get_stylesheet_directory_uri() . '/js/sitewide-non-handhelds.js', array( 'jquery' ), '1.0.0', true );
  22.     }
  23. }
  24.  
  25. add_action( 'genesis_loop', 'sk_fixed_cpt_nav' );
  26. /**
  27.  * Display links to previous and next entries.
  28.  *
  29.  * Context: Single Posts and 'movies' CPT's single entries, on desktops only.
  30.  *
  31.  */
  32. function sk_fixed_cpt_nav() {
  33.     if ( is_singular( array( 'post', 'movies' ) ) && ! wp_is_mobile() ) {
  34.         // http://codex.wordpress.org/Function_Reference/get_adjacent_post
  35.         // get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy )
  36.        
  37.         $prev_post = get_adjacent_post( false, '', true );
  38.  
  39.         $next_post = get_adjacent_post( false, '', false );
  40.  
  41.         if ( empty( $prev_post ) && empty( $next_post ) ) {
  42.             return;
  43.         } ?>
  44.  
  45.         <div class="btn-wrap">
  46.         <?php if ( !empty( $prev_post ) ) { ?>
  47.             <a class="prevBtn" href="<?php echo $prev_post->guid; ?>"><?php echo $prev_post->post_title; ?><i class="fa fa-chevron-left"></i></a>
  48.         <?php } ?>
  49.  
  50.         <?php if ( !empty( $next_post ) ) { ?>
  51.             <a class="nextBtn" href="<?php echo $next_post->guid; ?>"><i class="fa fa-chevron-right"></i><?php echo $next_post->post_title; ?></a>
  52.         <?php } ?>
  53.         </div>
  54.         <?php
  55.     }
  56. }
  57.  
  58. add_action( 'genesis_after_entry', 'sk_custom_post_nav' );
  59. /**
  60.  * Display links to previous and next entries.
  61.  *
  62.  * Context: Single Posts and 'movies' CPT's single entries, on handhelds only.
  63.  *
  64.  */
  65. function sk_custom_post_nav() {
  66.     if ( wp_is_mobile() && is_singular( array( 'post', 'movies' ) ) ) {
  67.         echo '<div class="prev-next-post-links">';
  68.         previous_post_link('<div class="previous-post-link">&laquo; %link</div>', '<strong>%title</strong>' );
  69.         next_post_link('<div class="next-post-link">%link &raquo;</div>', '<strong>%title</strong>' );
  70.         echo '</div>';
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement