Advertisement
fahimmurshed

How to create Astra theme custom Attachment page

May 4th, 2020 (edited)
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2. /**
  3.  * attachment.php
  4.  * The template for displaying all attachment single posts.
  5.  * Custom Attachment page by Fahim Murshed
  6.  * https://fahimm.com
  7.  *
  8.  * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
  9.  *
  10.  * @package Astra
  11.  * @since 1.0.0
  12.  */
  13.  
  14. if ( ! defined( 'ABSPATH' ) ) {
  15.     exit; // Exit if accessed directly.
  16. }
  17.  
  18. get_header(); ?>
  19.  
  20. <?php if ( astra_page_layout() == 'left-sidebar' ) : ?>
  21.  
  22.     <?php get_sidebar(); ?>
  23.  
  24. <?php endif ?>
  25.  
  26.     <div id="primary" <?php astra_primary_class(); ?>>
  27.  
  28.         <?php astra_primary_content_top(); ?>
  29.  
  30.         <h1 class="post-title"><?php the_title(); ?></h1>
  31.  
  32.         <?php
  33.         echo wp_get_attachment_image( get_the_ID(), 'large' );
  34.  
  35.         echo "<hr><p class='resolutions'> Downloads: ";
  36.  
  37.         $images = array();
  38.         $image_sizes = get_intermediate_image_sizes();
  39.         array_unshift( $image_sizes, 'full' );
  40.         foreach( $image_sizes as $image_size ) {
  41.             $image = wp_get_attachment_image_src( get_the_ID(), $image_size );
  42.             $name = $image_size . ' (' . $image[1] . 'x' . $image[2] . ')';
  43.             $images[] = '<a href="' . $image[0] . '">' . $name . '</a>';
  44.         }
  45.  
  46.         echo implode( ' | ', $images );
  47.         echo "</p>";
  48.  
  49.         astra_content_loop();
  50.         ?>
  51.  
  52.  
  53.  
  54.         <?php
  55.  
  56.         ?>
  57.         </p>
  58.  
  59.  
  60.         <?php astra_primary_content_bottom(); ?>
  61.  
  62.     </div><!-- #primary -->
  63.  
  64. <?php if ( astra_page_layout() == 'right-sidebar' ) : ?>
  65.  
  66.     <?php get_sidebar(); ?>
  67.  
  68. <?php endif ?>
  69.  
  70. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement