Here’s the code:
// [showfiles]
function dump_files($atts) {
extract(shortcode_atts(array(), $atts));
global $post;
$return = '';
$children = get_children( 'numberposts=-1&orderby=menu_order&order=ASC&post_type=attachment&post_parent='.$post->ID );
if ($children) :
$return .= '<ul>';
foreach ($children as $child) {
$return .= '<li>
<a href="'.$child->guid.'">'.$child->post_title.'</a>';
if ($child->post_content):
$return .='<br>'.$child->post_content;
endif;
$return .='</li>';
} // endfor
$return .='</ul>';
endif;
return $return;
}
add_shortcode("showfiles", "dump_files");
// end shortcode
More later…stay tuned.
I needed this functionality, and decided to create a function. Since it was so easily digestable, I figured I’d just post it here. Here’s the function function set_post_background() { global $post; $bgimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID…
I haven’t posted in a very long time, but as soon as I stumbled on this functionality I had to share it immediately, so here it is: It is possible to add a filter function to add new text to the password protected page. The code to add to your functions.php files is as follows: <?php add_filter( '…
Today I launched the new design of Escape From Cubicle Nation, which I’m very proud to have worked on. Props to Brian Morykon for the design, Joseph Hinson for the code. My last order of business in coding the site was that some of the Youtube videos and embeds had been inserted at a width of 640 pix…
Tim wrote a series when I first started called “The 21 Days of WordPress Tips”, which I think there were something like 18 of…but I digress. We’ve been getting traffic on those posts for awhile, and he knew I was geeking out over here, so he told me to export them to this blog an…
If you’ve ever been upgrading a WordPress installation and had it fail, leaving you in the dark depths of maintenance mode, you’ll agree with me that it can be quite a headache. Much like a site launch or a database move, it can take either 5 minutes, or 5 hours, but it never seems to fall in b…
I was trying to create a sub-navigation menu that would only show if there were child pages in WordPress the other day, but to my knowledge, there is no has_children() or has_child() type of conditional available. I’m sure it’s because there are so many other ways to check for children.…
In my work I create a lot of WordPress sites for my clients, and often times we’ll put the share links and social proof in the footer of each post. Some time ago, facebook introduced the like button for public use with iframes, which makes it very easy to incorporate just about anywhere, the only p…
I write a lot of code snippets on this site, some stuff is found by searching for the solution to a specific problem, others are found by trying to do new things with WordPress. I was thinking of creating a site with code Snippets that could be downloaded by anyone who stumbled on the site, and submitted b…
{0}