0
votes

Thank you all in advance for any information and help!

I'm trying to make a plugin that creates an admin page on my Wordpress site that will allow me to display custom content without hard coding it into the theme every time I need to change it.

I want to create an admin page with form inputs that I can enter information into(text, urls, images) that I can then echo into locations across my theme.

I've done something similar with a plugin I made to show metabox fields for my single.php blog posts. This allowed me to put things into my post like, subtitles, author names, and images.

I used this page as a reference to create that. https://metabox.io/how-to-create-custom-meta-boxes-custom-fields-in-wordpress/

add_action('admin_menu', 'add_global_custom_options');

function add_global_custom_options()
{
    add_menu_page('Global Custom Options', 'Theme Options', 'manage_options', 'functions','global_custom_options');
}

function global_custom_options()
{
?>


 <input type="hidden" name="your_meta_box_nonce" value="<?php echo wp_create_nonce( basename(__FILE__) ); ?>">

                <!--Article Subtitle-->
                      <p>
                      <label style="font-weight:700; font-size:1.2em;" for="your_fields[articlesubtitle]">Article Subtitle</label>
                      <br>
                      <input type="text" name="your_fields[articlesubtitle]" id="your_fields[articlesubtitle]" class="regular-text" value="<?php echo $meta['articlesubtitle']; ?>">
                  </p><br>

                <!--Article Author-->
                          <p>
                        <label style="font-weight:700; font-size:1.2em;" for="your_fields[text]">Author Name</label>
                        <br>
                        <input type="text" name="your_fields[authorname]" id="your_fields[authorname]" class="regular-text" value="<?php echo $meta['authorname']; ?>">
                      </p><br>

                <!--Article Author Title-->
                      <p>
                    <label style="font-weight:700; font-size:1.2em;" for="your_fields[authortitle]">Author Title</label>
                    <br>
                    <input type="text" name="your_fields[authortitle]" id="your_fields[authortitle]" class="regular-text" value="<?php echo $meta['authortitle']; ?>">


<?php
}
1

1 Answers

0
votes

You can use the Redux framework plugin(https://wordpress.org/plugins/redux-framework/) to create a theme settings page for your theme where you can set different kinds of data which you'll be able to access anywhere on your theme template files.

Here are some links to get started-

  1. https://code.tutsplus.com/tutorials/getting-started-with-redux-framework-introducing-it-and-integrating-it-into-your-theme--cms-22240
  2. https://www.youtube.com/watch?v=b6RjlIrCHwo
  3. https://docsv3.redux.io/core/getting-started/

Thanks.