Skip to content

Instantly share code, notes, and snippets.

@scottwyden
Created March 27, 2015 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottwyden/9555926ae344d3e8f512 to your computer and use it in GitHub Desktop.
Save scottwyden/9555926ae344d3e8f512 to your computer and use it in GitHub Desktop.
Photocrati Theme Attachment Page Mods in Functions.php
// Attachement Page Modifications
add_action('generate_rewrite_rules', 'attachment_rewrite_rule_14924');
function attachment_rewrite_rule_14924($wp_rewrite){
$new_rules = array();
$new_rules['attachment/(\d*)$'] = 'index.php?attachment_id=$matches[1]';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action( '__after_content' ,'my_attachment_description' );
function my_attachment_description() {
global $post;
if ( ( isset($post) && 'attachment' != $post -> post_type) || !is_singular() || empty( $post->post_content ) )
return;
?>
<section>
<p class="text-center muted">
<?php echo strip_tags(apply_filters ('the_excerpt', $post->post_content)) ?>
</p>
</section>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment