Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I add custom generated text to posts using text from tags?

Something like: [Post Title] + custom text + tags + custom text ....

Or is there a plugin which does this ?

share|improve this question
add comment

1 Answer

There is no plugin for that... at least one plugin :)

Create custom fileds for your custom text. Install ACF plugin (advanced custom fields) from wordpress.org.

Now... create a field group with ACF and then create custom fileds inside that group for your custom text 1 and custom text 2. (Don't forget to assign field group to post and/or pages.)

Use

 <?php the_field('custom_text_1'); ?>

and

 <?php the_field('custom_text_2'); ?>

inside page/post template to display your custom text 1 and custom text 2.

You can try to call tags with get the tag list

<?php
echo get_the_tag_list('<p>Tags: ',', ','</p>');
?>

Finaly, you can call Title with

<?php the_title(); ?>

So... just place this snippet inside your template on place where you want to show your record:

<?php the_title(); ?> <?php the_field('custom_text_1'); ?> <?php echo get_the_tag_list('<p>Tags: ',', ','</p>'); ?> <?php the_field('custom_text_2'); ?>

You can change custom_text_1 and custom_text_2 with records of your choice, but they must to be the same as you create them inside ACF.

If you want to display your record inside content area of your post or page, you can use any another plugin which can help you to create [short code] for given snippet.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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