php 创世纪没有帖子输出
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 创世纪没有帖子输出相关的知识,希望对你有一定的参考价值。
<?php
/**
* Update Genesis No Post Text
*
* @package Child Theme
* @author Patrick Boehner
* @copyright Copyright (c) 2017, Patrick Boehner
* @license GPL-2.0+
*
*/
//* Security Updates
//*****************************
if( !defined( 'ABSPATH' ) ) exit;
//* Add Widget for No Posts pages
//*****************************
genesis_register_sidebar( array(
'id' => 'no-posts-widget',
'name' => __( 'No Services Available', 'gentleheartyoga-2016' ),
'description'=> __( 'This widget area shows when no services are available. This widget area is meant to be used with a contact form.', 'gentleheartyoga-2016' ),
) );
<?php
/**
* Update Genesis No Post Text
*
* @package Child Theme
* @author Patrick Boehner
* @copyright Copyright (c) 2017, Patrick Boehner
* @license GPL-2.0+
*
*/
//* Security Updates
//*****************************
if( !defined( 'ABSPATH' ) ) exit;
//* Replace No Posts Section
//*****************************
remove_action( 'genesis_loop_else', 'genesis_do_noposts' );
add_action( 'genesis_loop_else', 'pb_custom_no_posts' );
function pb_custom_no_posts() {
echo '<div class="entry"><div class="entry-content">';
// Output Text
printf( '<p class="no-posts-message">%s</p>', apply_filters( 'genesis_noposts_text', __( 'Sorry, no content matched your criteria.', 'child-theme' ) ) );
// Output Widget Area
if ( is_post_type_archive( 'pb_cpt_services' ) || is_tax( 'service-category' ) && is_active_sidebar( 'no-posts-widget' ) ) {
genesis_widget_area ('no-posts-widget', array(
'before' => '<div class="no-posts-widget-area widget-area">',
'after' => '</div><!-- End of No Posts Widget Area -->',));
}
echo '</div></div>';
}
//* Update No Post Text
//*****************************
add_filter( 'genesis_noposts_text', 'leaven_change_search_text_one', 10, 2 );
function leaven_change_search_text_one( $text ) {
if ( is_search() ) {
$text = __( '<strong>Sorry, but nothing matched your search terms.</strong> Please try again with some different keywords.', 'child-theme' );
$text = $text . genesis_search_form();
}
if ( is_archive() ) {
$text = __( '<strong>Sorry, but I don\'t have any posts on that subject.</strong> Please try searching for something else.', 'child-theme' );
$text = $text . genesis_search_form();
}
if ( is_post_type_archive( 'pb_cpt_services' ) || is_tax( 'service-category' ) ) {
$text = __( '<strong>Sorry, there is nothing currently scheduled.</strong> I have new events coming all the time. If you would like to be kept up to date about availability or if you have a question, please get in touch. Let me know how I can best help you.', 'child-theme' );
// $text = $text . genesis_search_form();
}
if ( is_post_type_archive( 'pb_cpt_testimonials' ) || is_tax( 'testimonial-category' ) ) {
$text = __( '<strong>Sorry, there aren\'t any testimonials for this service yet.</strong> If you would like to contribute a testimonial or if you have a question please get in touch.', 'child-theme' );
}
return $text;
}
以上是关于php 创世纪没有帖子输出的主要内容,如果未能解决你的问题,请参考以下文章