• I built a static button from backend but i want that button get hyperlink from post editor.
    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.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    First you need to save the link destination somewhere. The easiest way is to add a custom field on a post edit screen. Once you add a field name, it will be available in a dropdown on any subsequent edit screen. It’s important that the exact same name be used every time.

    To use the added custom field’s value when outputting the link href, use echo get_post_meta( get_the_ID(), 'your_field_name', true );

    You can add extra code that uses a default value if getting the post meta value does not return anything.

Viewing 1 replies (of 1 total)
  • The topic ‘How use Dynamic hyperlink on each wordpress post?’ is closed to new replies.