Guest User

function.php

a guest
Jul 23rd, 2021
24
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function catchflames_page_content( $options ) {
  2. global $post;
  3.  
  4. $quantity = $options['featured_content_number'];
  5.  
  6. $show_content = $options['featured_content_show'];
  7.  
  8. $number_of_page = 0; // for number of pages
  9.  
  10. $page_list = array(); // list of valid pages ids
  11.  
  12. $catchflames_page_content = '';
  13.  
  14. //Get valid pages
  15. for( $i = 1; $i <= $quantity; $i++ ){
  16. if ( isset ( $options['featured_content_page'][ $i ] ) && $options['featured_content_page'][ $i ] > 0 ){
  17. $number_of_page++;
  18.  
  19. $page_list = array_merge( $page_list, array( $options['featured_content_page'][ $i ] ) );
  20. }
  21.  
  22. }
  23. if ( !empty( $page_list ) && $number_of_page > 0 ) {
  24. $loop = new WP_Query( array(
  25. 'posts_per_page' => $number_of_page,
  26. 'post__in' => $page_list,
  27. 'orderby' => 'post__in',
  28. 'post_type' => 'page',
  29. ));
  30.  
  31. $i=0;
  32. while ( $loop->have_posts()) : $loop->the_post(); $i++;
  33. $title_attribute = the_title_attribute( array( 'before' => __( 'Permalink to: ', 'catch-flames' ), 'echo' => false ) );
  34.  
  35. $excerpt = get_the_excerpt();
  36.  
  37. $catchflames_page_content .= '
  38. <article id="featured-post-' . $i . '" class="post hentry featured-page-content">';
  39. if ( has_post_thumbnail() ) {
  40. $catchflames_page_content .= '
  41. <figure class="featured-homepage-image">
  42. <a href="' . esc_url( get_permalink() ) . '" title="'.the_title( '', '', false ).'">
  43. '. get_the_post_thumbnail( $post->ID, 'full', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'pngfix' ) ) .'
  44. </a>
  45. </figure>';
  46. }
  47. else {
  48. $catchflames_first_image = catchflames_get_first_image( $post->ID, 'catch-flames-featured-content', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'pngfix' ) );
  49.  
  50. if ( '' != $catchflames_first_image ) {
  51. $catchflames_page_content .= '
  52. <figure class="featured-homepage-image">
  53. <a href="' . esc_url( get_permalink() ) . '" title="'.the_title( '', '', false ).'">
  54. '. $catchflames_first_image .'
  55. </a>
  56. </figure>';
  57. }
  58. }
  59.  
  60. $catchflames_page_content .= '
  61. <div class="entry-container">
  62. <header class="entry-header">
  63. <h1 class="entry-title">
  64. <a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . the_title( '','', false ) . '</a>
  65. </h1>
  66. </header>';
  67. if ( 'excerpt' == $show_content ) {
  68. $catchflames_page_content .= '<div class="entry-excerpt"><p>' . $excerpt . '</p></div><!-- .entry-excerpt -->';
  69. }
  70. elseif ( 'full-content' == $show_content ) {
  71. $content = apply_filters( 'the_content', get_the_content() );
  72. $content = str_replace( ']]>', ']]&gt;', $content );
  73. $catchflames_page_content .= '<div class="entry-content">' . wp_kses_post( $content ) . '</div><!-- .entry-content -->';
  74. }
  75. $catchflames_page_content .= '
  76. </div><!-- .entry-container -->
  77. </article><!-- .featured-post-'. $i .' -->';
  78. endwhile;
  79.  
  80. wp_reset_postdata();
  81. }
  82.  
  83. return $catchflames_page_content;
  84. }
RAW Paste Data