I am not a developer. But with your help I will try to do something myself.
Here is the overall code of post.php.
I want to show .ppt in all posts.
I want to show .ppt file from ifrem. But the URL of the ppt file attached in the post is not available.
Hope you will solve it.
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
function my_simple_crypt( $string, $action = 'e' ) {
$secret_key = 'drivekey';
$secret_iv = 'google';
$output = false;
$encrypt_method = "AES-256-CBC";
$key = hash( 'sha256', $secret_key );
$iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
if( $action == 'e' ) {
$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
}else if( $action == 'd' ){
$output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
}
return $output;
}
function remove_wp_block_file_div($content) {
$content = preg_replace('/<div class="wp-block-file">.*?<\/div>/s', '', $content);
return $content;
}
add_filter('the_content', 'remove_wp_block_file_div');
get_header();
?>
<?php
$args = array(
'post_type' => 'attachment', // Retrieve attachments
'post_mime_type' => 'application/vnd.ms-powerpoint', // Filter by MIME type for PPT files
'posts_per_page' => -1, // Retrieve all attachments
);
$attachments = new WP_Query($args);
$attachment_url = wp_get_attachment_url($attachment_id);
if ($attachments->have_posts()) :
while ($attachments->have_posts()) : $attachments->the_post();
$attachment_id = get_the_ID();
$attachment_title = get_the_title();
$attachment_url = wp_get_attachment_url($attachment_id);
endwhile;
endif;
wp_reset_postdata(); // Restore the original post data
?>`
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="content ringtone" data-id="<?php echo get_the_ID(); ?>" data-value="<?php echo $URLs_Link_MP3 ; ?>">
<div class="row">
<div class="col-md-12">
<h1><?php the_title(); ?> PPT</h1>
</div>
</div>
<div class="row">
<?php $attachment_url = wp_get_attachment_url($attachment_id); ?>
<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=<?php echo $attachment_url; ?>" width="100%" height="500" frameborder="0"></iframe>
</div>
<?php get_footer();