RUSSEL86

My Genesis cheetsheet

Jul 6th, 2018 (edited)
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.30 KB | None | 0 0
  1. // Add featured image on single post
  2. add_action( 'genesis_entry_header', 'themeprefix_featured_image', 1 );
  3. function themeprefix_featured_image() {
  4. $image = genesis_get_image( array( // more options here -> genesis/lib/functions/image.php
  5. 'format' => 'html',
  6. 'size' => 'large',// add in your image size large, medium or thumbnail - for custom see the post
  7. 'context' => '',
  8. 'attr' => array ( 'class' => 'aligncenter' ), // set a default WP image class
  9.  
  10. ) );
  11. if ( is_singular()) {
  12. if ( $image ) {
  13. printf( '<div class="featured-image-class">%s</div>', $image ); // wraps the featured image in a div with css class you can control
  14. }
  15. }
  16. }
  17.  
  18. // add class to body
  19. add_filter( 'body_class', 'add_body_class' );
  20. function add_body_class( $classes ) {
  21. $classes[] = 'custom-home-template';
  22. return $classes;
  23. }
  24.  
  25. // remove entry title
  26. //remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
  27.  
  28. //add html wrap page featured image and to display featured image
  29. add_action( 'genesis_entry_header', 'rtug_entry_header_first', 9 );
  30. function rtug_entry_header_first() {
  31.  
  32. echo '<div class="singular-featured-image">';
  33. genesis_image( array( 'size' => 'singular-featured-thumb' ) );
  34. echo '</div><div class="post-info-wrap">';
  35.  
  36. }
  37.  
  38. // entry header title modify
  39. add_filter( 'genesis_post_title_output', 'bn_post_title_output', 15 );
  40. function bn_post_title_output( $title ) {
  41.  
  42. if ( is_singular() ) {
  43. $title = sprintf( '<h1 class="entry-title">%s <br><span>Your Step-by-Step Guide To Getting Your First Blog Up and Running in No Time!</span></h1>', apply_filters( 'genesis_post_title_text', get_the_title() ) );
  44. return $title;
  45. }
  46. }
  47.  
  48. //add html content after header title tag
  49. add_action( 'genesis_entry_header', 'rtug_before_entry_content' );
  50. function rtug_before_entry_content() {
  51. echo '<span class="entry-lead">Guide by Karen Evans. Last updated: July 19th, 2018.</span></div>';
  52.  
  53. }
  54.  
  55. //add html wrap author_box
  56. add_action( 'genesis_before_entry_content', 'rtug_author_box' );
  57. function rtug_author_box() {
  58.  
  59. if ( is_page() )
  60. echo '<div class="main-author-box">';
  61. genesis_author_box( 'page', true );
  62. echo '</div>';
  63.  
  64. }
  65. //gravatar_size
  66. add_filter( 'genesis_author_box_gravatar_size', 'rtug_author_box_gravatar_size' );
  67. function rtug_author_box_gravatar_size() {
  68. return 216;
  69. }
  70. //remove author_box title
  71. add_filter( 'genesis_author_box_title', 'custom_author_box_title' );
  72. function custom_author_box_title() {
  73. return '';
  74. }
  75. //add html wrap author_box image and description
  76. add_filter( 'genesis_author_box', 'jivedig_remove_avatar_author_box', 10, 6 );
  77. function jivedig_remove_avatar_author_box( $output, $context, $pattern, $gravatar, $title, $description ) {
  78. echo '<div class="author-image">';
  79. echo $gravatar ;
  80. echo '</div>';
  81.  
  82. echo '<div class="author-bio">';
  83. echo $description ;
  84. echo '</div>';
  85.  
  86. }
  87.  
  88.  
  89. //Remove Avatar from Genesis Author Box
  90. add_filter( 'genesis_author_box', 'jivedig_remove_avatar_author_box', 10, 6 );
  91. function jivedig_remove_avatar_author_box( $output, $context, $pattern, $gravatar, $title, $description ) {
  92. return sprintf( $pattern, '', $title, $description );
  93. }
  94.  
  95. // Remove 'site-inner' from structural wrap
  96. add_theme_support( 'genesis-structural-wraps', array( 'header', 'footer-widgets', 'footer' ) );
  97.  
  98. //* Modify Leave a reply title text in comments
  99. add_filter( 'comment_form_defaults', 'topleague_comment_form_defaults' );
  100. function topleague_comment_form_defaults( $defaults ) {
  101.  
  102. $defaults['title_reply'] = __( 'Question and Answers' );
  103. return $defaults;
  104. }
  105. //* Modify comments title text in comments
  106. add_filter( 'genesis_title_comments', 'topleague_genesis_title_comments' );
  107. function topleague_genesis_title_comments() {
  108. $title = '<h3>Question and Answers</h3>';
  109. return $title;
  110. }
  111.  
  112. //* Customize the submit button text in comments
  113. add_filter( 'comment_form_defaults', 'topleague_comment_submit_button' );
  114. function topleague_comment_submit_button( $defaults ) {
  115.  
  116. $defaults['label_submit'] = __( 'Submit');
  117. return $defaults;
  118.  
  119. }
  120.  
  121.  
  122. //add your checkbox after the comment field
  123. add_filter( 'comment_form_field_comment', 'my_comment_form_field_comment' );
  124. function my_comment_form_field_comment( $comment_field ) {
  125. return $comment_field.'<p class="pprivacy"><input type="checkbox" name="privacy" value="privacy-key" class="privacyBox" aria-req="true">
  126. <label>I accept the <a target="blank" href="privacy-policy/">Privacy Policy</a></label><p>';
  127. }
  128.  
  129. //javascript validation
  130. add_action('wp_footer','valdate_privacy_comment_javascript');
  131. function valdate_privacy_comment_javascript(){
  132. if (comments_open()){
  133. wp_enqueue_script('jquery');
  134. ?>
  135. <script type="text/javascript">
  136. jQuery(document).ready(function($){
  137. $("#submit").click(function(e){
  138. if (!$('.privacyBox').prop('checked')){
  139. e.preventDefault();
  140. alert('You must agree to our privacy term by checking the box ....');
  141. return false;
  142. }
  143. })
  144. });
  145. </script>
  146. <?php
  147. }
  148. }
  149.  
  150. // Register a custom image size for Singular Featured images
  151. add_image_size( 'singular-featured-thumb', 840, 500, true );
  152.  
  153. // add html before comment form
  154. add_action( 'genesis_before_comments', 'rtug_genesis_before_comments' );
  155. function rtug_genesis_before_comments() {
  156. echo '
  157. <img src="'.get_stylesheet_directory_uri().'/images/arrow-down.png" class="aligncenter arrow-comments lazyloading" data-was-processed="true">
  158. <a href="#" id="comments-expander-trigger">
  159. <span class="comments-expander-text">';
  160.  
  161. comments_number( 'no Comments', 'one Comment', '% Comments' );
  162.  
  163. echo '</span>
  164. <span class="comments-expander-arrow" style="font-family: sans-serif;">»</span>
  165. </a>
  166.  
  167. <div id="comments-expander">
  168. ';
  169. }
  170.  
  171. add_action( 'genesis_after_comment_form', 'rtug_genesis_after_comments' );
  172. function rtug_genesis_after_comments() {
  173. echo '</div>';
  174. }
  175.  
  176. // add html before footer
  177. add_action( 'genesis_before_footer', 'rtug_genesis_before_footer' );
  178. function rtug_genesis_before_footer() {
  179. echo '<section class="sites-count">
  180. <div class="holder">
  181. <div class="data">
  182. <i class="fa fa-laptop"></i> <span>';
  183. $total = wp_count_posts()->publish;
  184. echo $total;
  185. echo ' blogs created with this guide... and counting!</span>
  186. </div>
  187. </div>
  188. </section>
  189. ';
  190. }
  191.  
  192. //Remove Existing Footer
  193. remove_action( 'genesis_footer', 'genesis_do_footer' );
  194.  
  195. /**
  196. * Add Footer Widget to Genesis
  197. *
  198. * @link http://wpbeaches.com/create-footer-widget-area-genesis-child-theme/
  199. */
  200. add_action( 'widgets_init', 'yourtheme_extra_widgets' );
  201. // Add in new Widget area
  202. function yourtheme_extra_widgets() {
  203. genesis_register_sidebar( array(
  204. 'id' => 'footercontent',
  205. 'name' => __( 'Footer', 'yourtheme' ),
  206. 'description' => __( 'This is the general footer area', 'yourtheme' ),
  207. 'before_widget' => '<div class="footercontent">',
  208. 'after_widget' => '</div>',
  209. ));
  210. }
  211.  
  212. add_action('genesis_footer','yourtheme_footer_widget');
  213. // Position the Footer Area
  214. function yourtheme_footer_widget() {
  215. genesis_widget_area ('footercontent', array(
  216. 'before' => '<div class ="footercontainer">',
  217. 'after' => '</div>',
  218. ));
  219. }
  220.  
  221. // footer menu function
  222. function wdm_add_footer_menu()
  223. {
  224. wp_nav_menu(array(
  225. 'container_id' => 'footer' ,
  226. 'menu_class' => 'menu-footer-menu',
  227. 'theme_location' => 'secondary',
  228. 'depth' => 1,
  229. 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>'
  230. ) );
  231. }
  232.  
  233. //remove footer menu
  234. remove_action( 'genesis_footer', 'genesis_do_subnav' );
  235.  
  236. // remove footer copyright text
  237. function wpb_footer_creds_text () {
  238. $copyright = '';
  239. return $copyright;
  240. }
  241. add_filter( 'genesis_footer_creds_text', 'wpb_footer_creds_text' );
  242.  
  243. // add content after footer area
  244. add_action( 'genesis_after_footer', 'rtug_genesis_after_footer' );
  245. function rtug_genesis_after_footer() {
  246.  
  247. echo '<section class="real_footer">
  248. <div class="wrap">
  249. <div class="three-sixths first credits">
  250. <p>©&nbsp;2018 · StartBloggingOnline · All Rights Reserved';
  251. echo '.</p> </div> <div class="three-sixths fmenu">';
  252.  
  253. wdm_add_footer_menu();
  254.  
  255.  
  256. echo '</div>
  257. </div>
  258. </section>';
  259.  
  260. }
  261.  
  262. //Modify Entire Footer Text (including markup)? please check this box genesis simple edit
  263. <div class="footer-copyright-wrap fix">
  264. <div class="wrap">
  265. [copyright_leftarea][copyright_middlearea][copyright_righttarea]
  266. </div>
  267. </div>
  268.  
  269.  
  270. // Moving Post Categories from Entry Meta to above Post Title in Genesis.
  271. ---------------------------------------
  272. //* Add Post categories above Post title on single Posts
  273. add_action ( 'genesis_entry_header', 'sk_show_category_name', 9 );
  274. function sk_show_category_name() {
  275. if ( ! is_singular('post') )
  276. return;
  277. echo do_shortcode('[post_categories before="Filed Under: "]');
  278. }
  279. //* Show only Post tags in entry meta for single Posts
  280. add_filter( 'genesis_post_meta', 'sk_post_meta_filter' );
  281. function sk_post_meta_filter($post_meta) {
  282. if ( is_singular('post') ) :
  283. $post_meta = '[post_tags]';
  284. else :
  285. endif;
  286. return $post_meta;
  287. }
  288. // Moving Post Info above Post Title in Genesis.
  289. -------------------------------------------
  290. //* Position post info above post title
  291. remove_action( 'genesis_entry_header', 'genesis_post_info', 12);
  292. add_action( 'genesis_entry_header', 'genesis_post_info', 9 );
  293.  
  294.  
  295. // add content between the Post title and the author and date info.
  296. ----------------------------
  297. add_action( 'genesis_entry_header', 'rtug_entry_header' );
  298. function rtug_entry_header() {
  299. echo '<p>A piece of extra content between the title and byline</p>';
  300. }
  301. -- or --
  302. add_action( 'genesis_post_title', 'rtug_entry_header' );
  303. function rtug_entry_header() {
  304. echo '<p>A piece of extra content between the title and byline</p>';
  305. }
  306.  
  307. // add content directly above the Post or Page title.
  308. ----------------------------
  309. add_action( 'genesis_entry_header', 'rtug_entry_header_first', 9 );
  310. function rtug_entry_header_first() {
  311. echo '<p>A piece of extra content directly above the title</p>';
  312. }
  313. -- or --
  314. add_action( 'genesis_post_title', 'rtug_entry_header_first', 9 );
  315. function rtug_entry_header_first() {
  316. echo '<p>A piece of extra content directly above the title</p>';
  317. }
  318.  
  319. // wrap entry titles inside a custom div in Genesis
  320. ---------------------------
  321. // Add custom opening div for post title
  322. add_action( 'genesis_entry_header', 'sk_do_post_title_before', 7 );
  323. function sk_do_post_title_before() {
  324. echo '<div class="my-entry-title">';
  325. }
  326.  
  327. // Add custom closing div for post title
  328. ------------------------------
  329. add_action( 'genesis_entry_header', 'sk_do_post_title_after' );
  330. function sk_do_post_title_after() {
  331. echo '</div>';
  332. }
  333.  
  334. // add html after widget title
  335. ----------------------------------
  336. add_filter( 'dynamic_sidebar_params', 'b3m_wrap_widget_titles', 20 );
  337. function b3m_wrap_widget_titles( array $params ) {
  338. // $params will ordinarily be an array of 2 elements, we're only interested in the first element
  339. $widget =& $params[0];
  340. $widget['before_title'] = '<h4 class="widgettitle home_widget_title">';
  341. $widget['after_title'] = '</h4><div class="paloma-accent accent-small home_widgt">
  342. <svg xmlns="http://www.w3.org/2000/svg" width="41.4" height="9.5" viewBox="0 0 41.4 9.5">
  343. <path d="M40.7 8.1L34 1.4l-6.6 6.7-6.7-6.7L14 8.1 7.4 1.4.7 8.1" class="st0"></path>
  344. </svg>
  345. </div>';
  346.  
  347. return $params;
  348.  
  349. }
  350.  
  351. //Display Your Genesis Blog in Grid Layout
  352. //* Grid Style Content Archive
  353. function be_archive_post_class( $classes ) {
  354. // Don't run on single posts or pages
  355. if( !is_home() )
  356. return $classes;
  357. $classes[] = 'one-third';
  358. global $wp_query;
  359. if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 3 )
  360. $classes[] = 'first';
  361. return $classes;
  362. }
  363. add_filter( 'post_class', 'be_archive_post_class' );
  364.  
  365. function he_archive_post_class( $classes ) {
  366. // Don't run on single posts or pages
  367. if( !is_category() )
  368. return $classes;
  369. $classes[] = 'one-third';
  370. global $wp_query;
  371. if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 3 )
  372. $classes[] = 'first';
  373. return $classes;
  374. }
  375. add_filter( 'post_class', 'he_archive_post_class' );
Advertisement
Add Comment
Please, Sign In to add comment