如何在每个WordPress帖子上使用动态超链接?

时间:2017-02-11 作者:tony

I have designed a static design and button on singlepost.php file now i want that when i create a new post then i want to put a hyperlink behind that button from post editor section. how can i do that ?

how i set hyperlink behind that "Get Deal" button from post page ?

Get Deal button is static for all post but this button take link when i put from post editor section (so there will be separate dynamic link for each post)

My static design code for post is :

<div class="price_row_grid">
    <div class="price_for_grid floatleft">
        <?php theme_create_btn(\'no\', \'price\'); ?>

    </div>

    <div class="floatright vendor_for_grid">
        <?php if ($price_meta == \'admin\'): ?>
            <?php $author_id = $post->post_author; ?>
            <a class="admin" href="<?php echo get_author_posts_url($author_id) ?>" title="<?php the_author_meta(\'display_name\', $author_id); ?>">
                <?php echo get_avatar($author_id, \'22\'); ?>
            </a>
        <?php elseif ($price_meta == \'store\'): ?>
            <div class="brand_logo_small">
                <?php WPSM_Postfilters::re_show_brand_tax(\'logo\'); //show brand logo?>
            </div>
        <?php endif; ?>
    </div>
</div>


 <div class="price_row_grid">
        <div class="price_for_grid floatleft">
            <p class="button">Get Deal</p>



        </div>

Now how i set hyperlink behind "Get Deal" from post editor because i just build button which is static for all pages but i want to set different hyperlink for each page.

1 个回复
最合适的回答,由SO网友:user6552940 整理而成

您需要在编辑后的屏幕上创建一个自定义元数据库,下面是一个tutorial 关于如何做到这一点

本教程将允许您在后期编辑屏幕上有另一个名为\'Get Deals\'

遵循该教程后,替换

\'smashing\\u post\\u class\'with \'get\\u deals\\u link“

  • \'Post Class”with \'Get Deals添加一个自定义CSS类,该类将应用于WordPress的“post类”with \'获取交易链接,然后像这样打印您的按钮

    <a href="<?php echo get_post_meta( $post->ID, \'get_deals_link\', true );?>"
    class="button">Get Deal</a>
    
    希望这对你有帮助。

  • 相关推荐

    无法在模板函数.php中使用IS_HOME

    我试图在标题中加载一个滑块,但只在主页上加载。如果有帮助的话,我正在使用Ultralight模板。我正在尝试(在template functions.php中)执行以下操作:<?php if ( is_page( \'home\' ) ) : ?> dynamic_sidebar( \'Homepage Widget\' ); <?php endif; ?> 但这行不通。现在,通过快速的google,我似乎需要将请