最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - Custom download page

programmeradmin0浏览0评论

I have stored URLs in post meta for a custom post type. I need to create a page that lists the download links.

When someone clicks on a download link they should be redirected to the corresponding download page, such as example/download.php and after 5 seconds, the downloading of the file (identified by the link stored in post meta) should start automatically

If you need demo to see please see apkpure or getintopc. When downloading a file, it goes to getintopc/getsoft.php, then the download starts.

I have stored URLs in post meta for a custom post type. I need to create a page that lists the download links.

When someone clicks on a download link they should be redirected to the corresponding download page, such as example/download.php and after 5 seconds, the downloading of the file (identified by the link stored in post meta) should start automatically

If you need demo to see please see apkpure or getintopc. When downloading a file, it goes to getintopc/getsoft.php, then the download starts.

Share Improve this question edited Aug 3, 2017 at 20:48 Porosh Ahammed asked Aug 3, 2017 at 19:46 Porosh AhammedPorosh Ahammed 3232 silver badges10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Finally I solve the problem. Here the code bellow for download button. Put this code into your post loop it will show a download button.

     <form action="<?php echo esc_url( home_url( '/your_redirected_page_slug' ) ); ?>" method="GET" id="form1">
    <?php  global $post;
         //$post_slug=$post->post_name;

    ?>
    <input id="myButton" type="submit" name="a" value="Download" class="single-download-button" />
     <input type="hidden" name="appk" id="mkval" value="<?php echo get_the_ID(); ?>" />                                                  
 </form>

When someone click on that button it will redirect to download page. Then put the code bellow to that page:

<?php
$id = $_GET['appk']; // get form data 
$popularpost = new WP_Query( array('post_type' => 'your_cusom_post_name',
     'posts_per_page' => 9, 
     // 'meta_key' => 'wpb_post_views_count', 
     //'orderby' => 'meta_value_num',                               
     'order' => 'DESC',
     'p' => $id, 
      ) );


    while ( $popularpost->have_posts() ) : $popularpost->the_post();
    $id = get_the_ID();

    ?>


    <!-- Your Code Function here -->

<?php
    endwhile;
    // Reset Post Data
        wp_reset_postdata();
    ?> 

Thats it...... enjoy

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论