我怎样才能在帖子里得到头衔?

时间:2013-11-25 作者:Oliver

我有一个自定义的网格循环,可以在页面上显示特定的帖子类型。

这显示了每个帖子的EXERTP,但它不包含帖子标题,我希望每个帖子都有一个链接到完整帖子的标题。有人能帮忙吗?

谢谢

<?php
/**
  * @author Jonathan Perez
 */

/*
Template Name: Grid Loop for Press Releases
*/

// Do the Custom Loop
remove_action(\'genesis_loop\', \'genesis_do_loop\');
add_action( \'genesis_loop\', \'sf_custom_loop\' );

function sf_custom_loop() {


        echo \'<h3 class="entry-title media-title">\' . get_the_title() . \'</h3>\';
        the_content();

        //WP Query Start

        $per_page = 9;

        $product_args = array(
            \'post_type\' => \'pressreleases\',
            \'posts_per_page\' => $per_page,
                            \'paged\' => get_query_var( \'paged\' )
        );
        $products = genesis_custom_loop( $product_args );
}

//Add Post Class Filter
add_filter(\'post_class\', \'sf_post_class\');
function sf_post_class($classes) {
    global $loop_counter;
    if ($loop_counter % 3 == 0) {
        $classes[] .= \'first \';
    }
    return $classes;
}



/** Move Post Info */
remove_action(\'genesis_before_post_content\',\'genesis_post_info\');
remove_action(\'genesis_after_post_content\',\'genesis_post_meta\');

genesis();

1 个回复
SO网友:Chip Bennett

如果您只想将文章标题包装在永久链接中,请更改以下内容:

echo \'<h3 class="entry-title media-title">\' . get_the_title() . \'</h3>\';
。。。对此:

echo \'<a href="\' . get_permalink() . \'"><h3 class="entry-title media-title">\' . get_the_title() . \'</h3></a>\';
法典参考:get_permalink()

结束