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

customization - I want to change url structure of my created archieve pages

programmeradmin3浏览0评论

i have created custom template in which i have run query from database . in the page i have run loop from database

so i am taking id through url to another page and the link is creating like this so i want to change this link from this

/?file_id=1

to this

/

code is here

<?php
$results = $wpdb->get_results($wpdb->prepare('SELECT * FROM  share_files where status = 1 '));

foreach ($results as $r)
{
    $item_name = $r->title;
    $item_description = $r->description;
    $img_path = $r->img_name;
    $download = $r->file_path;
    $cat_id = $r->category;
    $file_id = $r->id;
    $date = $r->post_date ;
    $cat_res = $wpdb->get_results($wpdb->prepare('SELECT * FROM  wp_files_cat where file_id = '.$cat_id .''));
    ?>
    <div class="row" style=" margin:20px 0 ;border-bottom:1px #d8d8d8 dashed">
                <div class="col-md-2 hidden-xs">
               <a href="<?php echo bloginfo('url') ?>/single-share-file?file_id=<?php echo $file_id ?>"><img src="<?php echo $img_path ?> "></a>
                </div>

Thanks in Advance!!!!

i have created custom template in which i have run query from database . in the page i have run loop from database

so i am taking id through url to another page and the link is creating like this so i want to change this link from this

https://www.taxnetwork.in/single-share-file/?file_id=1

to this

https://www.taxnetwork.in/single-share-file/file_name/

code is here

<?php
$results = $wpdb->get_results($wpdb->prepare('SELECT * FROM  share_files where status = 1 '));

foreach ($results as $r)
{
    $item_name = $r->title;
    $item_description = $r->description;
    $img_path = $r->img_name;
    $download = $r->file_path;
    $cat_id = $r->category;
    $file_id = $r->id;
    $date = $r->post_date ;
    $cat_res = $wpdb->get_results($wpdb->prepare('SELECT * FROM  wp_files_cat where file_id = '.$cat_id .''));
    ?>
    <div class="row" style=" margin:20px 0 ;border-bottom:1px #d8d8d8 dashed">
                <div class="col-md-2 hidden-xs">
               <a href="<?php echo bloginfo('url') ?>/single-share-file?file_id=<?php echo $file_id ?>"><img src="<?php echo $img_path ?> "></a>
                </div>

Thanks in Advance!!!!

Share Improve this question edited Dec 16, 2019 at 8:47 Hakimuddin Saifee asked Dec 16, 2019 at 8:35 Hakimuddin SaifeeHakimuddin Saifee 392 silver badges10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Try add_rewrite_rule(), here's tutorial on how to use it https://www.pmg/blog/a-mostly-complete-guide-to-the-wordpress-rewrite-api/

发布评论

评论列表(0)

  1. 暂无评论