在标题中放置“中的链接”;阅读更多“;php WP

在标题中放置“中的链接”;阅读更多“;php WP,php,wordpress,function,echo,Php,Wordpress,Function,Echo,需要PHP帮助,所以我遇到了一个wordpress问题,我有显示标题内容和继续阅读文本的函数,我需要在标题中放置继续阅读文本的链接并隐藏继续阅读文本。以下是生成以下标题的文件中的代码: function whisper_entry_title2() { if ( !( $title = get_the_title() ) ) return; // Check on singular pages $is_single = is_singular()

需要PHP帮助,所以我遇到了一个wordpress问题,我有显示标题内容和继续阅读文本的函数,我需要在标题中放置继续阅读文本的链接并隐藏继续阅读文本。以下是生成以下标题的文件中的代码:

    function whisper_entry_title2()
{
    if ( !( $title = get_the_title() ) )
        return;

    // Check on singular pages
    $is_single = is_singular() && !is_page_template( 'tpl/blog.php' ) && !is_page_template( 'tpl/blog-boxes.php' );

    // Allow to config via global variable
    if ( isset( $whisper['is_single'] ) )
        $is_single = $whisper['is_single'];

    $tag = $is_single ? 'h1' : 'h2';
    $title = sprintf( '<b class="black">%4$s</b>', $tag, get_permalink(), the_title_attribute( 'echo=0' ), $title );
    echo apply_filters( __FUNCTION__, $title );


}
函数耳语\u条目\u标题2()
{
如果(!($title=获取标题())
返回;
//检查单数页
$is_single=is_singular()&&!is_page_模板('tpl/blog.php')&!is_page_模板('tpl/blog box.php');
//允许通过全局变量进行配置
如果(isset($whisper['is_single']))
$is_single=$whisper['is_single'];
$tag=$is_single?'h1':'h2';
$title=sprintf('%4$s',$tag,get_permalink(),_title_属性('echo=0'),$title);
回声应用过滤器(函数标题);
}
下面是生成继续阅读的代码部分:

function whisper_content_limitoffer1( $num_words, $more = '...', $echo = true )
{
    $content = get_the_content();

    // Strip tags and shortcodes so the content truncation count is done correctly
    $content = strip_tags( strip_shortcodes( $content ), apply_filters( 'whisper_content_limit_allowed_tags', '<script>,<style>' ) );

    // Remove inline styles / scripts
    $content = trim( preg_replace( '#<(s(cript|tyle)).*?</\1>#si', '', $content ) );

    // Truncate $content to $max_char
    $content = wp_trim_words( $content, $num_words );

    if ( $more )
    {
        //$event_id = get_post_meta(get_the_ID(),'event_id', TRUE);
        //$link="http://example.com/wp/events-offers/";
        $output = sprintf(
            '<p class="event2-cf-oe">%s <a href="%s" class="more-link right o_6" title="%s">%s</a></p>',
            $content,
            get_permalink(),
            sprintf( __( 'Continue reading &quot;%s&quot;', 'whisper' ), the_title_attribute( 'echo=0' ) ),
            $more
        );
    }
    else
    {
        $output = sprintf( '<p class="event2-cf-oe">%s</p>', $content );
    }

    // Still display post formats differently
    $output = whisper_post_formats_content( $output );

    if ( $echo )
        echo $output;
    else
        return $output;
}
函数whisper\u content\u limitoffer1($num\u words,$more='…',$echo=true)
{
$content=获取内容();
//剥离标记和短代码,以便正确完成内容截断计数
$content=strip_标记(strip_短代码($content),应用_过滤器('whisper_content_limit_allowed_标记',',');
//删除内联样式/脚本

$content=trim(preg_replace)(“#您的“继续阅读”文本由读取的行输出

sprintf( __( 'Continue reading &quot;%s&quot;', 'whisper' ), the_title_attribute( 'echo=0' ) ),
所以只要去掉那一行,文本就消失了。尽管我怀疑你可能会想要去掉那整段代码

$output = sprintf(
        '<p class="event2-cf-oe">%s <a href="%s" class="more-link right o_6" title="%s">%s</a></p>',
        $content,
        get_permalink(),
        sprintf( __( 'Continue reading &quot;%s&quot;', 'whisper' ), the_title_attribute( 'echo=0' ) ),
        $more
    );
所以你可以重新定位

通过以下简单的Wordpress功能,您可以非常轻松地输出文章标题并将其作为文章的链接:

<a href="<?php echo get_permalink(); ?>">
    <?php the_title; ?>
</a>

<a href="<?php echo get_permalink(); ?>">
    <?php the_title; ?>
</a>