Guest User

Untitled

a guest
Oct 25th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. // Bring back the missing editor for Posts page
  2. add_action( 'edit_form_after_title', 'rgc_posts_page_edit_form' );
  3. function rgc_posts_page_edit_form( $post ) {
  4.  
  5. $posts_page = get_option( 'page_for_posts' );
  6.  
  7. if ( $posts_page === $post->ID ) {
  8. add_post_type_support( 'page', 'editor' );
  9. }
  10.  
  11. }
  12.  
  13. remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' );
  14. add_action( 'genesis_before_loop', 'sk_do_posts_page_heading' );
  15. /**
  16. * Add custom headline and page content to assigned posts page.
  17. *
  18. * If we're not on a posts page, then nothing extra is displayed.
  19. *
  20. * @since 2.2.1
  21. *
  22. * @return null Return early if `headings` is not enabled for Genesis accessibility, there is no
  23. * page for posts assigned, this is not the home (posts) page, or this is not the page found at `/`.
  24. */
  25. function sk_do_posts_page_heading() {
  26.  
  27. if ( ! genesis_a11y( 'headings' ) ) {
  28. return;
  29. }
  30.  
  31. $posts_page = get_option( 'page_for_posts' );
  32.  
  33. if ( is_null( $posts_page ) ) {
  34. return;
  35. }
  36.  
  37. if ( ! is_home() || genesis_is_root_page() ) {
  38. return;
  39. }
  40.  
  41. $title = get_post( $posts_page )->post_title;
  42.  
  43. $content = get_post( $posts_page )->post_content;
  44.  
  45. $title_output = $content_output = '';
  46.  
  47. if ( $title ) {
  48. $title_output = sprintf( '<h1 %s>%s</h1>', genesis_attr( 'archive-title' ), get_the_title( $posts_page ) );
  49. }
  50.  
  51. if ( $content ) {
  52. $content_output = wpautop( $content );
  53. }
  54.  
  55. if ( $title || $content ) {
  56. printf( '<div %s>', genesis_attr( 'posts-page-description' ) );
  57. if ( $title ) {
  58. printf( '<h1 %s>%s</h1>', genesis_attr( 'archive-title' ), get_the_title( $posts_page ) );
  59. }
  60. echo '<div class="posts-page-intro">'. $content_output .'</div>';
  61. echo '</div>';
  62. }
  63.  
  64. }
Add Comment
Please, Sign In to add comment