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 badges1 Answer
Reset to default 0Try add_rewrite_rule(), here's tutorial on how to use it https://www.pmg/blog/a-mostly-complete-guide-to-the-wordpress-rewrite-api/