如何将插件的功能回显到模板中?

时间:2016-02-29 作者:sumnermic

我试过检查类似的问题,但找不到。如果可能,请将我链接到此,因为我可能正在创建副本。无论如何。。

我正在使用一个基本的推荐插件(干净的推荐),并希望创建一个允许的自定义模板。

我只想添加\\u client()和\\u website()函数。但是没有显示the\\u website()函数?

<div class="su-posts su-posts-default-loop">
<?php
    // Posts are found
    if ( $posts->have_posts() ) {
        while ( $posts->have_posts() ) :
            $posts->the_post();
            global $post;
            ?>

            <div id="su-post-<?php the_ID(); ?>" class="su-post">
                <?php if ( has_post_thumbnail() ) : ?>
                    <a class="su-post-thumbnail"><?php the_post_thumbnail(); ?></a>
                <?php endif; ?>
                <div class="su-post-content">
                    <p><?php the_content(); ?></p>
                    <p style="color:blue;"><?php echo the_client (); ?>, <?php echo the_website (); ?></p>
                </div>

            </div>

            <?php
        endwhile;
    }
    // Posts not found
    else {
        echo \'<h4>\' . __( \'Posts not found\', \'shortcodes-ultimate\' ) . \'</h4>\';
    }
?>

以下是功能。插件的php:

<?php
/*
Helper functions for Clean Testimonials
*/

function the_client () {

    global $post;

    return get_post_meta( $post->ID, \'testimonial_client_name\', true );

}

function get_the_client ( $testimonial_id ) {

    return get_post_meta( $testimonial_id, \'testimonial_client_name\', true );

}

function the_company () {

    global $post;

    return get_post_meta( $post->ID, \'testimonial_client_company\', true );

}

function get_the_company ( $testimonial_id ) {

    return get_post_meta( $testimonial_id, \'testimonial_client_company\', true );

}

function the_email () {

    global $post;

    return get_post_meta( $post->ID, \'testimonial_client_email\', true );

}

function get_the_email ( $testimonial_id ) {

    return get_post_meta( $testimonial_id, \'testimonial_client_email\', true );

}

function the_website () {

    global $post;

    return get_post_meta( $post->ID, \'testimonial_client_website\', true );

}

function get_the_website ( $testimonial_id ) {

    return get_post_meta( $testimonial_id, \'testimonial_client_website\', true );

}

function testimonial_has_permission( $testimonial_id ) {

    return get_post_meta( $testimonial_id, \'testimonial_client_permission\', true ) == \'yes\';

}

?>
谨致问候,

1 个回复
SO网友:Devendra Sharma

您可以使用以下代码。

get_the_client(get_the_ID());
get_the_company(get_the_ID());
get_the_website(get_the_ID());