首页 文章

在Wordpress Genesis子主题中自定义搜索结果页面

提问于
浏览
1

我正在为网站使用Wordpress和Genesis框架 . 我'm using a child theme (Ayoshop - not that it matters much) for the theme. I would like to customize the search results page by removing the '发布信息' area where it shows the date, author, and '留下评论'链接,而是显示该帖子的精选图片 . 主题是使用Genesis主题中的 search.php 页面,所以我不确定如何继续自定义它 .

以下是Genesis主题 search.php 的代码:

add_action( 'genesis_before_loop', 'genesis_do_search_title' );
/**
 * Echo the title with the search term.
 *
 * @since 1.9.0
 */
function genesis_do_search_title() {

    $title = sprintf( '<div class="archive-description"><h1 class="archive-title">%s %s</h1></div>', apply_filters( 'genesis_search_title_text', __( 'Search Results for:', 'genesis' ) ), get_search_query() );

    echo apply_filters( 'genesis_search_title_output', $title ) . "\n";

}

genesis();

1 回答

  • 2

    实际上它确实是Ayoshop主题,在一个名为 theme-tweaks.php 的文件中添加了一个自定义过滤器,删除了原始帖子信息并添加了自定义帖子信息,因此我需要删除该自定义操作 .

    所有更改都在 functions.php 文件中完成 .

    我确保删除了genesis_post_info,然后删除了Ayoshop添加的自定义操作 .

    remove_action( 'genesis_before_post_content', 'genesis_post_info' );
    remove_action( 'genesis_before_post_content', 'ayo_post_info' );
    

    然后,我添加了一个动作,将图像添加到帖子中 .

    add_action ( 'genesis_before_post_content', 'jl_post_info' );
    
    function jl_post_info() 
        if ( has_post_thumbnail() ) {
            printf( '<div class="post-info">' . get_the_post_thumbnail() . '</div>');
        }
    }
    

相关问题