How to Get the Files Under Downloads to Open in a New Page

  1. Home
  2. Docs
  3. Januas
  4. Frequently Asked Question...
  5. How to Get the Files Under Downloads to Open in a New Page

How to Get the Files Under Downloads to Open in a New Page

You can open the files in a new window by making the following changes in the code. It is easy, just follow the next steps:

 

1. Remember to take a backup of the files you are going to edit before any update.

2. Open the file wp-content/themes/januas/lib/metaboces/metabox-files.php

3. You will see a code like below:

$link = wp_get_attachment_link($file->ID);

4. Replace that line with the following:

$link = wp_get_file_attachment_link($file->ID);

5. Open wp-content/themes/januas/lib/januas.php and add this code at the bottom of the page

/* function to open the download files in a new window */

function wp_get_file_attachment_link( $id = 0, $size = ‘thumbnail’, $permalink = false, $icon = false, $text = false ) {
$id = intval( $id );
$_post = get_post( $id );

if ( empty( $_post ) || ( ‘attachment’ != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
return __( ‘Missing Attachment’ );

if ( $permalink )
$url = get_attachment_link( $_post->ID );

$post_title = esc_attr( $_post->post_title );

if ( $text )
$link_text = $text;
elseif ( $size && ‘none’ != $size )
$link_text = wp_get_attachment_image( $id, $size, $icon );
else
$link_text = ”;

if ( trim( $link_text ) == ” )
$link_text = $_post->post_title;

return apply_filters( ‘wp_get_attachment_link’, “<a href=’$url’ target=’_blank’ title=’$post_title’>$link_text</a>”, $id, $size, $permalink, $icon, $text );
}

6. Update both files.

Was this article helpful to you? Yes 1 No 1