Why can templates only be implemented in the header file?

Quote from The C++ standard library: a tutorial and handbook: The only portable way of using templates at the moment is to implement them in header files by using inline functions. Why is this? (Clarification: header files are not the only portable solution. But they are the most convenient portable solution.) 1 17 Caveat: It … Read more

single-{$post_type}-{slug}.php for custom post types

My favorite part of the WordPress template hierarchy is the ability to quickly create template files for pages by slug, without having to edit the page in WordPress to select a template. We can currently do this: page-{slug}.php But I would like to be able to do this: single-{post_type}-{slug}.php So that, for example, in a … Read more

How to rearrange fields in comment_form()

Im using a custom filter to change the fields, but can´t figure out how to change the order of the fields in the comment form. Desired order: comment field (first/top) name email website This is the code which I am currently using: function alter_comment_form_fields($fields){ $fields[‘comments’] = ‘Test’; $fields[‘author’] = ‘<p class=”comment-form-author”>’ . ‘<label for=”author”>’ . … Read more

Custom templates not showing up in template dropdown

I’ve got some problems with templates in WordPress (multisite). I’ve created a file in the root of my child-theme folder (template-test.php) <?php /** * Template Name: Test template * */ ?> <?php get_header(); ?> <?php get_footer(); ?> This template is not showing up in the templates dropdown when creating a new page, or editing an … Read more

Is there any way to use get_template_part() with folders?

I’m wondering if there is any way to use get_template_part() with folders? My main folder has a lot of files now because I put every re-usable element in a separate file. I’d like to put them in folders then. There is no information about that in Codex: http://codex.wordpress.org/Function_Reference/get_template_part 3 In fact you can, I have … Read more

How do I get the size of an attachment file?

I’m using the following template code to display attachment links: $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $main_post_id ); $attachments = get_posts($args); foreach ($attachments as $attachment) { the_attachment_link($attachment->ID, false); } but after the link I need to display the file’s size. How can I do this? I’m guessing … Read more