网址重写或更改wordpress网站链接的网址

时间:2013-09-04 06:48:38

标签: php wordpress .htaccess url-rewriting

我在wordpress中建立了以下网站 http://www.drwagenberg.com/之前的开发人员创建了四个模板页面 并创建具有不同类别的帖子中的所有内容。其中一个是模板页面代码

<?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(); ?>

然后在每个模板页面上检查所调用的类别,并从该模板页面上的数据库加载该类别。所以网址看起来像这样

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

永久链接设置为此类型

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

是否有任何简单的方法将地址栏中显示的网址设置为我想要的类型,如

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

以及如何为SEO优化做这个???

1 个答案:

答案 0 :(得分:0)

设置&gt;固定链接

使用“自定义结构”选项将其更改为您想要的格式。将以下代码复制并粘贴到其中,它将在您的网站上发生变化:

%category%/%postname%/