0

I have this code in my theme:

<div class="article-navigation">
                    <?php previous_post_link('<div class="navigation-item  navigation-item--previous">%link</div>', 
                                sprintf('<span class="arrow"></span>
                                        <div class="navigation-item__content">
                                            <div class="navigation-item__wrapper">
                                                <span class="button-title">%s</span>
                                                <h3 class="post-title">%%title</h3>
                                            </div>
                                        </div>', 
                                __('Previous Article', 'border_txtd')) ); ?>

                    <?php next_post_link('<div class="navigation-item  navigation-item--next">%link</div>', 
                                sprintf('<span class="arrow"></span>
                                        <div class="navigation-item__content">
                                            <div class="navigation-item__wrapper">
                                                <span class="button-title">%s</span>
                                                <h3 class="post-title">%%title</h3>
                                            </div>
                                        </div>',
                                __('Next Article', 'border_txtd')) ); ?>
                </div>

I want the 'Previous' and the 'Next' buttons to pull a Custom Field called 'HTML_title' instead of the regular 'Title'.

Thank you.

1
  • That sprintf( '%%title' ) won't work. Also the function is missing the second string.
    – kaiser
    Oct 24 '14 at 21:01
1

You will want to read up on get_post_meta(). Here is a link to the WP Codex reference for that function.

<?php $meta_values = get_post_meta( $post_id, $key, $single ); ?>

If you created that custom field with something like Elliot Condon's ACF plugin, the documentation for the plug-in is also helpful in meeting your exact need.

Assuming you are inside the loop so something like this should produce what you want:

$key_title = get_post_meta( get_the_ID(), 'yourkeyname', true );
echo $key_title;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.