Snippets
Created by
Joseph Dickson
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | <?php
/**
* The default template for displaying content
*
* Used for both singular and index.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WordPress
* @subpackage Twenty_Twenty
* @since Twenty Twenty 1.0
*/
?>
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<?php
if ( is_home() ) {
if ( function_exists( 'jd_testimonial_custom_post_type' ) ) {
// JD Testimonial Custom Post Types
get_template_part( 'template-parts/query-welcome' );
get_template_part( 'template-parts/query-testimonial' );
}
}
?>
<?php
get_template_part( 'template-parts/entry-header' );
if ( ! is_search() ) {
get_template_part( 'template-parts/featured-image' );
}
?>
<div class="post-inner <?php echo is_page_template( 'templates/template-full-width.php' ) ? '' : 'thin'; ?> ">
<div class="entry-content">
<?php
if ( is_search() || ! is_singular() && 'summary' === get_theme_mod( 'blog_content', 'full' ) ) {
the_excerpt();
} else {
the_content( __( 'Continue reading', 'twentytwenty' ) );
}
?>
</div><!-- .entry-content -->
</div><!-- .post-inner -->
<div class="section-inner">
<?php
wp_link_pages(
array(
'before' => '<nav class="post-nav-links bg-light-background" aria-label="' . esc_attr__( 'Page', 'twentytwenty' ) . '"><span class="label">' . __( 'Pages:', 'twentytwenty' ) . '</span>',
'after' => '</nav>',
'link_before' => '<span class="page-number">',
'link_after' => '</span>',
)
);
edit_post_link();
// Single bottom post meta.
twentytwenty_the_post_meta( get_the_ID(), 'single-bottom' );
if ( is_single() ) {
get_template_part( 'template-parts/entry-author-bio' );
}
?>
</div><!-- .section-inner -->
<?php
if ( is_single() ) {
get_template_part( 'template-parts/navigation' );
}
/**
* Output comments wrapper if it's a post, or if comments are open,
* or if there's a comment number – and check for password.
* */
if ( ( is_single() || is_page() ) && ( comments_open() || get_comments_number() ) && ! post_password_required() ) {
?>
<div class="comments-wrapper section-inner">
<?php comments_template(); ?>
</div><!-- .comments-wrapper -->
<?php
}
?>
</article><!-- .post -->
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | <?php
/**
* Plugin Name: JD Testimonial
* Description: Custom Post Type for customer testimonials and Homepage welcome
* Version: 1.0
* License: GPL2
*/
// Prevent direct access to this file
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* https://codex.wordpress.org/Function_Reference/register_post_type#Arguments
*/
function jd_testimonial_custom_post_type() {
$labels = array(
'name' => 'Testimonial',
'singular_name' => 'Testimonial',
'menu_name' => 'Testimonial',
'name_admin_bar' => 'Testimonial',
'add_new' => 'Add a Testimonials',
'add_new_item' => 'Testimonial',
'new_item' => 'Testimonial',
'edit_item' => 'Edit Testimonial',
'view_item' => 'View Testimonial',
'all_items' => 'All Testimonials',
'search_items' => 'Search Testimonials',
'parent_item_colon' => 'Parent Testimonials:',
'not_found' => 'No Testimonials found.',
'not_found_in_trash' => 'No Testimonials found in Trash.',
);
$args = array(
'labels' => $labels,
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-format-chat',
'query_var' => true,
'rewrite' => array( 'slug' => 'testimonial' ),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => 16,
'show_in_rest' => true,
'supports' => array( 'title', 'editor', 'thumbnail' ),
);
register_post_type( 'testimonial', $args );
$labels = array(
'name' => 'Welcome',
'singular_name' => 'Welcome',
'menu_name' => 'Welcome',
'name_admin_bar' => 'Welcome',
'add_new' => 'Add a Homepage Welcome',
'add_new_item' => 'Welcome',
'new_item' => 'Welcome',
'edit_item' => 'Edit Welcome',
'view_item' => 'View Welcome Messages',
'all_items' => 'All Welcome Messages',
'search_items' => 'Search Welcome Messages',
'parent_item_colon' => 'Parent Welcome Messages:',
'not_found' => 'No Welcome Messages found.',
'not_found_in_trash' => 'No Homepage Welcome Messages found in the Trash.',
);
$args = array(
'labels' => $labels,
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-star-filled',
'query_var' => true,
'rewrite' => array( 'slug' => 'hp-welcome' ),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => 15,
'show_in_rest' => true,
'supports' => array( 'title', 'editor' ),
);
register_post_type( 'hp-welcome', $args );
}
add_action( 'init', 'jd_testimonial_custom_post_type' );
// Flush rewrite rules when plugin is activated
function pz_tile_rewrite_flush() {
pz_tile_custom_post_type();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'jd_testimonial_rewrite_flush' );
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
// delete the next line if you do not need additional image sizes
add_image_size( 'testimonial-thumb', 600, 600, array( 'center', 'center') );
}
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.