<?php /** * Template Name: Testimonial Archives * Description: Used as a page template to show page contents, followed by a loop through a CPT archive */ remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop add_action( 'genesis_loop', 'custom_do_loop' ); // Add custom loop function custom_do_loop() { // Intro Text (from page content) echo '<div class="page hentry entry">'; echo '<h1 class="entry-title">'. get_the_title() .'</h1>'; echo '<div class="entry-content">' . get_the_content() ; $args = array( 'post_type' => 'testimonials', // enter your custom post type 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page'=> '12', // overrides posts per page in theme settings ); $loop = new WP_Query( $args ); if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post(); global $post; echo '<div id="testimonials">'; echo '<div class="one-fourth first">'; echo '<div class="testimonial-image">'. get_the_post_thumbnail( $id, array(150,150) ).'</div>'; echo '<cite>' . genesis_get_custom_field( '_cd_client_name' ) . '</cite>'; //retrieve custom field echo '<br />' . genesis_get_custom_field( '_cd_client_title' ); //retrieve custom field echo '</div>'; echo '<div class="three-fourths">'; echo '<h3>' . get_the_title() . '</h3>'; echo '<blockquote>' . get_the_content() . '</blockquote>'; echo '</div>'; echo '</div>'; endwhile; endif; // Outro Text (hard coded) echo '<div class="call-to-action">My call to action text. <a href="">Contact me</a></div>'; echo '</div><!-- end .entry-content -->'; echo '</div><!-- end .page .hentry .entry -->'; } /** Remove Post Info */ remove_action('genesis_before_post_content','genesis_post_info'); remove_action('genesis_after_post_content','genesis_post_meta'); genesis();
Genesis Full width custom page template
<?php /** * This file adds a custom template to the AgentPress Child Theme. * * @author Brad Dalton * @link http://wpsites.net/web-design/make-custom-page-template/ * @package Agentpress * @subpackage Customizations */ /* Template Name: Custom */ // Add custom body class to the head add_filter( 'body_class', 'add_body_class' ); function add_body_class( $classes ) { $classes[] = 'agentpress-custom'; return $classes; } // Force full width page layout add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); genesis();
How to create template page in Genesis in WordPress?
Put this in the functions.php
<?php /** * Template Name: Office Hours Template * Description: Used as a page template to show page contents, followed by a loop * through the "Genesis Office Hours" category */ // Add our custom loop add_action( 'genesis_loop', 'cd_goh_loop' ); function cd_goh_loop() { $args = array( 'category_name' => 'genesis-office-hours', // replace with your category slug 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page'=> '12', // overrides posts per page in theme settings ); $loop = new WP_Query( $args ); if( $loop->have_posts() ) { // loop through posts while( $loop->have_posts() ): $loop->the_post(); $video_id = esc_attr( genesis_get_custom_field( 'cd_youtube_id' ) ); $video_thumbnail = '<img src="http://img.youtube.com/vi/' . $video_id . '/0.jpg" alt="" />'; $video_link = 'http://www.youtube.com/watch?v=' . $video_id; echo ' <div class="one-third first">'; echo '<a href="' . $video_link . '" target="_blank">' . $video_thumbnail . '</a>'; echo '</div> '; echo ' <div class="two-thirds"> '; echo ' <h4>' . get_the_title() . '</h4> '; echo ' ' . get_the_date() . ' '; echo ' <a href="' . $video_link . '" target="_blank">Watch It</a> | <a href="' . get_permalink() . '" target="_blank">Show Notes</a> '; echo '</div> '; endwhile; } wp_reset_postdata(); } genesis();
How to create Custom Post Types in Genesis Child Theme in WordPress
Put below code to the functions.php of the child theme.
add_action( 'init', 'create_custom_post_type' ); function create_custom_post_type() { $labels = array( 'name' => __( 'Tax Liens' ), 'singular_name' => __( 'Tax Lien' ) ); $args = array( 'labels' => $labels, 'public' => true, 'has_archive' => true, 'rewrite' => array('slug' => 'taxliens'), ); register_post_type( 'tax_lien', $args); }