mohawktopus
Forum Replies Created
-
Forum: Plugins
In reply to: Filter and display attachmentsI 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_extarray) 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
In reply to: Display Custom Field Data in PagesMaybe I’m not. I’m gonna see if
wp_page_menu()is a better option.Forum: Plugins
In reply to: Display Custom Field Data in PagesI 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
In reply to: Display Custom Field Data in PagesSo 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
In reply to: Filter and display attachmentsI 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
In reply to: Display Custom Field Data in PagesSo WP treats pages exactly like posts?
Forum: Plugins
In reply to: Enumerating shortcode gallery imagesI figured it out finally, but it was a while back now, and I don’t remember how…
Forum: Fixing WordPress
In reply to: Adding Images from Library to GalleryThis 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
In reply to: Enumerating shortcode gallery imagesI meant that I edited the template pages of Single Post and Single page. (By going to the
Design > Theme Editordealio.)