本文整理汇总了PHP中get_template_part函数的典型用法代码示例。如果您正苦于以下问题:PHP get_template_part函数的具体用法?PHP get_template_part怎么用?PHP get_template_part使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_template_part函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bap_ajaxP_loop
function bap_ajaxP_loop($offset = '')
{
global $wp_query;
$paged = get_query_var('page') ? get_query_var('page') : 1;
$do_not_duplicate = array();
// OFFSET SETTING
if (!$offset == '' || !$offset == '0') {
$argshidepost = array('numberposts' => $offset, 'post_type' => 'post', 'post_status' => 'publish');
$hide_to_array = get_posts($argshidepost);
// HIDE OFFSETED POSTS
if ($hide_to_array) {
foreach ($hide_to_array as $post) {
$do_not_duplicate[] = $post->ID;
}
}
}
$argsmain = array('post_type' => 'post', 'post_status' => 'publish', 'paged' => $paged, 'order' => 'DESC', 'post__not_in' => $do_not_duplicate);
$wp_query = new WP_Query($argsmain);
if ($wp_query->have_posts()) {
echo '<section id="' . bap_get_option_text('bap_loopContainer') . '">';
while ($wp_query->have_posts()) {
$wp_query->the_post();
get_template_part('partials/listitem');
}
echo '</section>';
}
wp_reset_postdata();
}
示例2: cmb_initialize_cmb_meta_boxes
/**
* Initialize the metabox class.
*/
function cmb_initialize_cmb_meta_boxes()
{
if (!class_exists('cmb_Meta_Box')) {
get_template_part('framework/metabox/init');
get_template_part('framework/metabox/meta-custom');
}
}
示例3: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
$sticky = get_option('sticky_posts');
$number = empty($instance['number']) ? 1 : (int) $instance['number'];
$cat = empty($instance['category']) ? 0 : (int) $instance['category'];
if (is_single()) {
array_push($sticky, get_the_ID());
}
echo $before_widget;
if (!empty($title)) {
echo $before_title . $title . $after_title;
} else {
echo '<br />';
}
$featuredPosts = new WP_Query(array('posts_per_page' => $number, 'cat' => $cat, 'post__not_in' => $sticky, 'no_found_rows' => true));
while ($featuredPosts->have_posts()) {
$featuredPosts->the_post();
global $mb_content_area, $more;
$mb_content_area = 'sidebar';
get_template_part('content', get_post_format());
}
wp_reset_postdata();
echo $after_widget;
}
示例4: doublecheeseburger_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function doublecheeseburger_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
示例5: us_web_standards_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function us_web_standards_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
示例6: component_s_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function component_s_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('components/content', get_post_format());
}
}
示例7: theme_posts_shortcode
/**
* Shortcode functionality to show posts.
*
* @since 1.0.0
*/
function theme_posts_shortcode($atts)
{
$output = false;
// Pull in shortcode attributes and set defaults
$defaults = array('category' => '', 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => '10', 'tag' => '');
// Process shortcode attribtues
$atts = shortcode_atts($defaults, $atts, 'show-posts');
// Set up initial query for post
$args = array('category_name' => $atts['category'], 'order' => $atts['order'], 'orderby' => $atts['orderby'], 'posts_per_page' => $atts['posts_per_page'], 'tag' => $atts['tag'], 'ignore_sticky_posts' => 1, 'no_found_rows' => true);
$query = new WP_Query($args);
if ($query->have_posts()) {
global $wp_query;
// Backup the main query.
$saved_query = $wp_query;
// Replace the main query by reference.
$wp_query = $query;
// Capture the output so we can return it to the shortcode process.
ob_start();
echo '<div class="show-posts-wrapper">';
while ($wp_query->have_posts()) {
$wp_query->the_post();
get_template_part('content', get_post_format());
}
echo '</div>';
$output = ob_get_clean();
// Clean up after ourselves.
$wp_query = $saved_query;
wp_reset_postdata();
}
return $output;
}
示例8: my_theme_wrapper_end
function my_theme_wrapper_end()
{
echo '</div></div></section>';
echo '<div class="shop_bottom">';
get_template_part('bottom-content');
echo '</div>';
}
示例9: portarlington_cce_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function portarlington_cce_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
示例10: gabfire_theme_scripts
function gabfire_theme_scripts()
{
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/framework/bootstrap/css/bootstrap.min.css');
wp_enqueue_style('font-awesome', get_template_directory_uri() . '/framework/font-awesome/css/font-awesome.min.css');
wp_enqueue_style('bootstrap-social', get_template_directory_uri() . '/css/bootstrap-social.css');
wp_enqueue_style('colorbox-css', get_template_directory_uri() . '/css/colorbox.css');
wp_enqueue_style('animate-css', get_template_directory_uri() . '/css/animate.css');
//wp_enqueue_style('owl-carousel', get_template_directory_uri() .'/css/owl.carousel.css');
//wp_enqueue_style('flat-ui', get_stylesheet_directory_uri() .'/css/flat-ui.css'); // adding FLAT UI to main header query
wp_enqueue_style('datatables-css', '//cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css');
wp_enqueue_style('theme-style', get_stylesheet_uri(), false);
// NEW: Add Ion Icons
wp_enqueue_style('ion-icons', get_template_directory_uri() . '/framework/ion-icons/css/ionicons.min.css');
get_template_part('css/customizedcss', '');
wp_enqueue_script('jquery');
wp_enqueue_script('bootstrap', get_template_directory_uri() . '/framework/bootstrap/js/bootstrap.min.js');
wp_enqueue_script('modernizr', get_template_directory_uri() . '/inc/js/modernizr.custom.js');
wp_enqueue_script('responsive-nav', get_template_directory_uri() . '/inc/js/responsive-menu.js');
//wp_enqueue_script('wow', get_template_directory_uri() .'/inc/js/wow.min.js');
//wp_enqueue_script('shuffle', get_template_directory_uri() .'/inc/js/jquery.shuffle.min.js');
wp_enqueue_script('jquery-colorbox', get_template_directory_uri() . '/inc/js/jquery.colorbox-min.js');
//wp_enqueue_script('owl-carousel', get_template_directory_uri() .'/inc/js/owl.carousel.min.js');
//wp_enqueue_script('stellar', get_template_directory_uri() .'/inc/js/stellar.js');
//wp_enqueue_script('froogaloop', '//f.vimeocdn.com/js/froogaloop2.min.js');
//wp_enqueue_script('youtube-api', '//www.youtube.com/player_api');
wp_enqueue_script('datatables-js', '//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js');
if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
if (file_exists(get_stylesheet_directory() . '/custom.css')) {
wp_enqueue_style('custom-style', get_stylesheet_directory_uri() . '/custom.css');
} elseif (file_exists(get_template_directory_uri() . '/custom.css')) {
wp_enqueue_style('custom-style', get_template_directory_uri() . '/custom.css');
}
}
示例11: crum_search_form
function crum_search_form($form)
{
ob_start();
get_template_part('templates/searchform');
$form = ob_get_clean();
return $form;
}
示例12: sfhiv_preview_shortcode
function sfhiv_preview_shortcode($atts, $content = null)
{
global $post;
extract(shortcode_atts(array('id' => false, 'title' => false, 'replace_title' => false, 'replace_content' => false, 'template' => 'preview'), $atts));
$preview_post = false;
$return_content = "";
if (isset($title)) {
$preview_post = get_page_by_title($title);
}
if (isset($id) && !$preview_post) {
$num = (int) $id;
$preview_post = get_post($num);
}
if ($preview_post) {
$org_post = $post;
$post = $preview_post;
if ($replace_title) {
$post->post_title = $replace_title;
}
if ($content != null) {
$post->post_content = $content;
$post->post_excerpt = $content;
}
if ($replace_content) {
$post->post_content = $replace_content;
$post->post_excerpt = $replace_content;
}
ob_start();
get_template_part($template, $post->post_type);
$return_content = ob_get_clean();
$post = $org_post;
}
return $return_content;
}
示例13: checkout_render_infinite_posts
function checkout_render_infinite_posts()
{
while (have_posts()) {
the_post();
get_template_part('partials/content-standard');
}
}
示例14: x_get_view
function x_get_view($stack, $base, $extension = '')
{
$file = $stack . '_' . $base . (empty($extension) ? '' : '-' . $extension);
do_action('x_before_view_' . $file);
get_template_part('framework/views/' . $stack . '/' . $base, $extension);
do_action('x_after_view_' . $file);
}
示例15: ebor_testimonial_shortcode
/**
* The Shortcode
*/
function ebor_testimonial_shortcode($atts)
{
extract(shortcode_atts(array('pppage' => '999', 'filter' => 'all', 'type' => 'carousel-3col'), $atts));
/**
* Initial query args
*/
$query_args = array('post_type' => 'testimonial', 'posts_per_page' => $pppage);
if (!($filter == 'all')) {
if (function_exists('icl_object_id')) {
$filter = (int) icl_object_id($filter, 'testimonial_category', true);
}
$query_args['tax_query'] = array(array('taxonomy' => 'testimonial_category', 'field' => 'id', 'terms' => $filter));
}
/**
* Finally, here's the query.
*/
global $wp_query;
$wp_query = new WP_Query($query_args);
ob_start();
get_template_part('loop/loop-testimonial', $type);
wp_reset_postdata();
$output = ob_get_contents();
ob_end_clean();
return $output;
}