php - url rewriting or chage urls for wordpress website links

441

i've the following website built in wordpress http://www.drwagenberg.com/ the previous developer has created four template pages and creates all the things in posts with different categories.here is one of template page code

<?php
/*
Template Name: detail
*/
?><?php get_header(); ?>
<?php include (TEMPLATEPATH . '/banner.php'); ?>
<div id="inner_servce_bx">   <!-- inner service bx -->

<?php $cat_id=$_GET['catid']; ?> 
<div id="inner_heading">
<?php  $title = $wpdb->get_results( "SELECT * FROM $wpdb->terms WHERE term_id=$cat_id"); 
    foreach ($title as $objt)  {
    $main_title =  $objt->name; ?>
  <div id="inner_hdng_txt"><?php echo $main_title; ?></div>
  <?php } ?>
  </div> 

  <div id="servcs_smal_bx">  <!-- service service bx -->

<?php  $service_id = $wpdb->get_results( "SELECT * FROM $wpdb->term_taxonomy WHERE parent=7 order by term_id asc"); 
foreach ($service_id as $obj)  {
$service_cat_id =  $obj->term_id; ?>
<?php  $service_name = $wpdb->get_results( "SELECT * FROM $wpdb->terms WHERE term_id=$service_cat_id"); 
foreach ($service_name as $obj1)  {
$service_cat_name =  $obj1->name;
$service_cat_id = $obj1->term_id; ?>

        <div id="servcs_smal_bx1">  <!-- servcs smal bx1 -->
        <div id="servc_title_bx">  <!-- servc title bx -->
          <div id="title_txt"><?php echo $service_cat_name; ?><br/>
<span id="title_txt1"><?php echo category_description( $service_cat_id ); ?></span></div>
<!-- servc title bx end -->
        <?php query_posts("cat=$service_cat_id&meta_key=short_desc" );  ?>      
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>            
<div id="servc_sml_img"><?php echo get_post_meta($post->ID, 'short_img', true); ?></div>
<?php endwhile; ?>
<?php endif; ?>
</div> <!-- servc title bx end -->
<?php query_posts("cat=$service_cat_id&meta_key=short_desc" );  ?>      
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <div id="serv_descrip"><?php echo get_post_meta($post->ID, 'short_desc', true); ?></div>
        <?php endwhile; ?>
        <?php endif; ?>
        <div id="read_mre1"><a href="index.php/?page_id=53&catid=<?php echo $service_cat_id; ?>">Read More...</a></div>
        <div id="ser_btm_line"><img src="<?php bloginfo('template_directory'); ?>/images/srvice_line.jpg" width="439" height="42" />
        </div>
        </div>
        <?php } } ?>

    </div>

</div> <!-- service service bx end -->
<?php get_footer(); ?>

then on each template page check for the category called and load that category from database on that template page. so the urls looks like this

http://www.drwagenberg.com/?page_id=101&catid=8

the permalinks are set to this type

post   http://www.drwagenberg.com/sample-post/

is there any easy way that the url's shown in the address bar are set to my desired type like

http://www.drwagenberg.com/services-procedures/periodontal-disease

and how i'll do this for SEO Optimization???

245

Answer

Solution:

Settings > Permalinks

Change it to the format you want there, using the Custom Structure option. Copy and paste the below code into there and it will change across your website:

%category%/%postname%/

People are also looking for solutions to the problem: Add namespace attribute to xml node in php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.