Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 893145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:10:25+00:00 2026-05-15T14:10:25+00:00

I’m writing a WordPress plugin which injects a grid of images just above the

  • 0

I’m writing a WordPress plugin which injects a grid of images just above the footer on all frontend pages. The application is to display sponsor’s logos. I’d like to harness the WP Media Library since the logos are already uploaded for use on the ‘sponsorship’ page and in posts.

Essentially I’m stuck at accessing the media library interface on the plugin’s options page. All of the legwork is done in terms of creating the options page, using the action hook to place content on frontend pages from the plugin, etc. What I need now is to be able to display all the files in the media library in a list on the options page, and provide a checkbox or something to allow the user to select certain files for insertion above the footer.

The Media Library API seems to be aimed at people writing themes or media plugins. Help understanding what to make use of would be great!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:10:26+00:00Added an answer on May 15, 2026 at 2:10 pm

    I think you’d be much better off adding your own column into the existing media library, rather than try re-coding it yourself;

    function my_media_col($cols)
    {
        $cols['my_col'] = 'Footer';
        return $cols;
    }
    add_filter('manage_media_columns', 'my_media_col');
    
    function handle_my_media_col($name, $id)
    {
        if ($name !== 'my_col')
            return false;
        $in_footer = get_option('in_footer', array());
    ?>
    <input type="checkbox" name="in_footer[]" value="<?php echo $id; ?>" <?php checked(in_array($id, $in_footer)); ?> />
    <?php
    }
    add_action('manage_media_custom_column', 'handle_my_media_col', 10, 2);
    

    Then just hook onto the load-upload.php (the library page) and save changes when POST’ed;

    function save_my_col()
    {
        if (!isset($_POST['in_footer']))
            return false;
    
        $in_footer = $_POST['in_footer'];
        if (is_array($in_footer))
            $in_footer = array_map('absint', $in_footer); // sanitize
        else
            $in_footer = array();
    
        $in_footer = array_merge(get_option('in_footer', array()), $in_footer);
        $in_footer = array_unique(array_filter($in_footer));
        update_option('in_footer', $in_footer);
    }
    add_action('load-upload.php', 'save_my_col');
    

    Note this is just an example, and I may have one or two typos.

    UPDATED:

    My code example should store an array of IDs in the options table, under the key ‘in_footer’.

    Put in practice, you can get all media items marked ‘in footer’ like so;

    $query = new WP_Query(array('post__in' => get_option('in_footer', array()) ));
    
    if ($query->have_posts()): while ($query->have_posts()): $query->the_post();
    ?>
    
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    
    <?php endwhile; endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.