Title: mohawktopus's Replies | WordPress.org

---

# mohawktopus

  [  ](https://wordpress.org/support/users/mohawktopus/)

 *   [Profile](https://wordpress.org/support/users/mohawktopus/)
 *   [Topics Started](https://wordpress.org/support/users/mohawktopus/topics/)
 *   [Replies Created](https://wordpress.org/support/users/mohawktopus/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/mohawktopus/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/mohawktopus/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/mohawktopus/engagements/)
 *   [Favorites](https://wordpress.org/support/users/mohawktopus/favorites/)

 Search replies:

## Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Filter and display attachments](https://wordpress.org/support/topic/filter-and-display-attachments/)
 *  Thread Starter [mohawktopus](https://wordpress.org/support/users/mohawktopus/)
 * (@mohawktopus)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/filter-and-display-attachments/#post-955611)
 * I finally made a solution! I feel so proud 🙂
 * Put this in `sidebar.php`:
 *     ```
       <li><h2>Recent Attachments</h2>
       <ul>
       <?php
       $valid_ext = array("pdf", "doc", "rtf", "zip");
       $args = array(
       	'post_type' => 'attachment',
       	'numberposts' => -1,
       	'post_status' => null,
       	'post_parent' => null, // any parent
       	);
       $attachments = get_posts($args);
       if ($attachments) {
       	foreach ($attachments as $post) {
       $ext = getFileExt(wp_get_attachment_url($post->ID, false));
       if(in_array($ext, $valid_ext)) {
        ?>
       <li>
       <?php
       	setup_postdata($post);
       	the_attachment_link($post->ID, true);
       ?>
       </li>
       <?php
                       }
       	}
       }
       ?>
       ```
   
 * And define `getFileExt()` in wp-includes/functions.php by pasting this at the
   bottom (before the final `?>`):
 *     ```
       function getFileExt($file) {
            return strtolower(substr(strrchr($file,'.'),1));
       }
       ```
   
 * This will put the latest uploads of particular extensions (defined by you in 
   the `$valid_ext` array) in your sidebar. I needed this because I’m creating a
   website for a Boy Scout troop, and the latest permission slips and agendas need
   to be on the front page, while any images or other media they may upload do not.
 * Hope this helps out someone else, too.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Display Custom Field Data in Pages](https://wordpress.org/support/topic/display-custom-field-data-in-pages/)
 *  Thread Starter [mohawktopus](https://wordpress.org/support/users/mohawktopus/)
 * (@mohawktopus)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/display-custom-field-data-in-pages/#post-955579)
 * Maybe I’m not. I’m gonna see if `wp_page_menu()` is a better option.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Display Custom Field Data in Pages](https://wordpress.org/support/topic/display-custom-field-data-in-pages/)
 *  Thread Starter [mohawktopus](https://wordpress.org/support/users/mohawktopus/)
 * (@mohawktopus)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/display-custom-field-data-in-pages/#post-955575)
 * I want to change `wp_list_pages()`, so when it iterates through each page, will
   also iterate through each page’s tagline meta_key and display that text alongside
   the page name.
 * `wp_list_pages()` comes into the discussion because I want that function to generate
   what I just described. So for each page displayed, it will also display that 
   page ID’s tagline metavalue.
 * Am I making sense?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Display Custom Field Data in Pages](https://wordpress.org/support/topic/display-custom-field-data-in-pages/)
 *  Thread Starter [mohawktopus](https://wordpress.org/support/users/mohawktopus/)
 * (@mohawktopus)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/display-custom-field-data-in-pages/#post-955376)
 * So in order to get the links & taglines the way I want, I should edit the wp_list_pages
   function to include the metadata from each post ID (since pages have post IDs)?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Filter and display attachments](https://wordpress.org/support/topic/filter-and-display-attachments/)
 *  Thread Starter [mohawktopus](https://wordpress.org/support/users/mohawktopus/)
 * (@mohawktopus)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/filter-and-display-attachments/#post-955371)
 * I found this snippet:
 *     ```
       <?php
       // list of approved file extensions
       $approved = array (
           'pdf' => "application/pdf",
           'doc' => "application/msword",
           'gif' => "image/gif",
           'jpg' => "image/jpeg",
           'jpeg' => "image/jpeg"
       };
   
       // for display purposes
       $filename = "index.html";
   
       // get the filename
       $ext = pathinfo($filename);
   
       switch (array_key_exists($ext['extension'], $approved)) {
           case true:
               break; // do nothing, break out...
           case false:
               echo $ext['extension'] ." is invalid!";
               exit;
           break;
       }
   
       ?>
       ```
   
 * Is there anyway to integrate this with the above to solve my problem?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Display Custom Field Data in Pages](https://wordpress.org/support/topic/display-custom-field-data-in-pages/)
 *  Thread Starter [mohawktopus](https://wordpress.org/support/users/mohawktopus/)
 * (@mohawktopus)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/display-custom-field-data-in-pages/#post-955370)
 * So WP treats pages exactly like posts?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Enumerating shortcode gallery images](https://wordpress.org/support/topic/enumerating-shortcode-gallery-images/)
 *  Thread Starter [mohawktopus](https://wordpress.org/support/users/mohawktopus/)
 * (@mohawktopus)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/enumerating-shortcode-gallery-images/#post-861151)
 * I figured it out finally, but it was a while back now, and I don’t remember how…
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Adding Images from Library to Gallery](https://wordpress.org/support/topic/adding-images-from-library-to-gallery/)
 *  Thread Starter [mohawktopus](https://wordpress.org/support/users/mohawktopus/)
 * (@mohawktopus)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/adding-images-from-library-to-gallery/#post-864292)
 * This is a two-parter, actually. How do you remove images from a post gallery 
   without deleting that image from the media library? And how do you add images
   to a post gallery without having to re-upload it?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Enumerating shortcode gallery images](https://wordpress.org/support/topic/enumerating-shortcode-gallery-images/)
 *  Thread Starter [mohawktopus](https://wordpress.org/support/users/mohawktopus/)
 * (@mohawktopus)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/enumerating-shortcode-gallery-images/#post-860710)
 * I meant that I edited the template pages of Single Post and Single page. (By 
   going to the `Design > Theme Editor` dealio.)

Viewing 9 replies - 1 through 9 (of 9 total)