Forum Replies Created

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Kiran

    (@kiranbhai)

    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(); 
    Thread Starter Kiran

    (@kiranbhai)

    I tried all but ppt url is not loading in the frame.

    Thread Starter Kiran

    (@kiranbhai)

    The output requires the URL of the PPT.

    check Our Test Page : https://pdfseva.org/2023/10/22/cold-chain-system/

    Thread Starter Kiran

    (@kiranbhai)

    Here we have mentioned the error code to explain the question in detail. In which the problem is coming. ( We have given the code from line 65 to 74 here. )

    {
    		foreach ( $this->formatted_favorites as $site => $site_favorites ){
    			// Make older posts compatible with new name
    			if ( !isset($site_favorites['posts']) ) {
    				$site_favorites['posts'] = $site_favorites['site_favorites'];
    				unset($this->formatted_favorites[$site]['site_favorites']);
    			}
    			foreach ( $site_favorites['posts'] as $key => $favorite ){
    				unset($this->formatted_favorites[$site]['posts'][$key]);
    				$this->formatted_favorites[$site]['posts'][$favorite]['post_id'] = $favorite;
    			}
    Thread Starter Kiran

    (@kiranbhai)

    I destroyed the cache in cloudflare and re-configure the setup and the problem was solved.

    Thread Starter Kiran

    (@kiranbhai)

    But other website is in same server – same cpanel there is no problem in it.

    Thread Starter Kiran

    (@kiranbhai)

    Working ….. I put this code and it is working successfully.

    // Get the current post's tags
        $tags = wp_get_post_tags( $post->ID );
        $tagIDs = array();
        if ( $tags ) {
            // Fill an array with the current post's tag ids
            $tagcount = count( $tags );
            for ( $i = 0; $i < $tagcount; $i++ ) {
                $tagIDs[$i] = $tags[$i]->term_id;
            }
            // Query options, the magic is with 'tag__in'
            $args = array(
                'tag__in' => $tagIDs,
                'post__not_in' => array( $post->ID ),
                'showposts'=> 5
            );
            $my_query = new WP_Query( $args );
    
    Thread Starter Kiran

    (@kiranbhai)

    I have prepared this related post loop. But is not working. Can you give any suggestion on this?

    function rtones_related_post() {   ?>
        <?php
        global $wpdb, $post, $opt_themes;
        $tags = get_post_tags($post->ID);
        $numbers = 	$opt_themes['ex_themes_related_posts_numbers_'];
        if ($tags) {
            $tag_ids = array();
            foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
            $args=array(
                //'tag' => $tags->slug,
                'post_type' => 'post',
                'post_status' => 'publish',
                'orderby'   => 'rand',
                'post__not_in' => array($post->ID),
                'posts_per_page'=> $numbers,
                'caller_get_posts'=> 1
            );
            $my_query = new WP_Query( $args );
            if( $my_query->have_posts() ) {
                while ($my_query->have_posts()) : $my_query->the_post(); ?>
                    <?php get_template_part('template/loop.home'); ?>
                <?php endwhile; }
            echo '';
            wp_reset_query();
        }?>
    <?php }
    
    Thread Starter Kiran

    (@kiranbhai)

    Yes, saw it, but it’s not working. Somebody help me please.

    Thread Starter Kiran

    (@kiranbhai)

    Oh… Very good. Been trying since two days. Its Working Fine. Thanks @threadi

Viewing 10 replies - 1 through 10 (of 10 total)