I created a plugin which shows custom posts (news). I have also added some admin setting fields for the plugin as well (Ex. number of posts). I also want to add a textarea where I can add HTML markup with PHP. This chunk of code will be the markup for each news item. This is something similar to the contact form 7 plugin where you can add markup for the form. But it also uses shortcode I guess.

In current version of my plugin I wrote the output markup in a plugin class file. This is not great if I want to make it universal and easily customisable the output. So I was thinking that I would add a setting field in admin where user can add/modify HTML markup.

Here is my output markup which is inside a php loop:

<div class="small-12 medium-6 columns itembox" data-totalitems="<?php echo $the_query->found_posts; ?>">
    <?php echo $aa['textarea']; ?>
    <div>

        <?php if (get_the_post_thumbnail()): ?>
            <a href="<?php the_permalink(); ?>" title="Go to <?php the_title(); ?>" class="not-text-link thumbnail"><?php the_post_thumbnail('news-thumb'); ?></a>
        <?php else: ?>
            <a href="<?php the_permalink(); ?>" title="Go to <?php the_title(); ?>" class="not-text-link thumbnail"><img src="http://placehold.it/558x310"></a>
        <?php endif; ?>


        <div class="news-intro">
            <time datetime="<?php echo get_the_date('d.m.Y'); ?>"><?php echo get_the_date('d.m.Y'); ?></time>

            <a href="<?php the_permalink(); ?>" title="Go to <?php the_title(); ?>" class="not-text-link"><h3><?php the_title(); ?></h3></a>
            <?php the_excerpt(); ?>

            <div class="addthis_toolbox">
                <div class="custom_images">
                    <a class="addthis_button_facebook not-text-link"><i class="icon-facebook"></i></a>
                    <a class="addthis_button_linkedin not-text-link"><i class="icon-linkedin"></i></a>
                </div>
            </div>

        </div>
    </div>
</div>

Read more here: Adding output markup for wordpress plugin as settings


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: