自定义搜索引擎友好链接 Permalinks Customizer插件

在建立CMS网站、或者需要自定义类型、数据库时,经常需要让条目的url对搜索引擎具备友好含义,以便加快收录速度及增加收录数量。

对于默认post、page内容,WordPress提供了内置的修改方式。但是对于自定义类型 Custom Post Type、一些复杂的要求,就需要扩展插件来进行配置。

Permalinks Customizer插件就能很好的满足要求。

Permalinks Customizer

Customize your URL and set the slug. You can use basic keywords which is defined by the WordPress for defining the permalinks as well as some new keywords which is defined by this plugin. All the keywords are defined on the Tags page under Permalinks Customizer.

By using Permalinks Customizer you can set the different permalink structure for each PostType and Taxonomy.

HOW TO SET THE PERMALINKS FOR THE POSTTYPES SEPARATELY

Let’s assume that you have 6 PostTypes and they all have different style of permalinks. Like:

  1. Blog : For this post type you want to create a permalink which looks like this: http://www.example.com/blog/year-month-date-postname/
  2. Customers : For this post type you want to create a permalink which looks like this: http://www.example.com/customers/postname/
  3. Events : For this post type you want to create a permalink which looks like this: http://www.example.com/events/year-month-date-postname/
  4. Press : For this post type you want to create a permalink which looks like this: http://www.example.com/press/category/year/postname/
  5. News : For this post type you want to create a permalink which looks like this: http://www.example.com/news/year/postname/
  6. Sponsors : For this post type you want to create a permalink which looks like this: http://www.example.com/company/sponsor/post_title/

This plugin allows you to do this very easily. You just need to go on Permalinks Customizer Settings Page. Where text fields are shown with PostType name. You can define your permalinks you want to create for each post type.

If you leave any PostType field empty. So, Permalinks Customizer would create a permalink for that PostType by using the default permalinksettings.

How to Configure Permalinks Customizer

You can configure the plugin by going to the menu Permalinks Customizer that appears in your admin menu.

OR

http://www.example.com/wp-admin/admin.php?page=permalinks-customizer-posts-settings

STRUCTURE TAGS

TAGS FOR POSTTYPES

  • %title% : Title of the post. let’s say the title is “This Is A Great Post!” so, it becomes this-is-a-great-post in the URI.
  • %year% : The year of the post, four digits, for example 2004
  • %monthnum% : Month of the year, for example 05
  • %day% : Day of the month, for example 28
  • %hour% : Hour of the day, for example 15
  • %minute% : Minute of the hour, for example 43
  • %second% : Second of the minute, for example 33
  • %post_id% : The unique ID # of the post, for example 423
  • %postname% : A sanitized version of the title of the post (post slug field on Edit Post/Page panel). So “This Is A Great Post!” becomes this-is-a-great-post in the URI.
  • %parent_postname% : A sanitized version of the title of the post (post slug field on Edit Post/Page panel). So “This Is A Great Post!” becomes this-is-a-great-post in the URI. This Tag contains Immediate Parent Page Slug if any parent page is selected before publishing.
  • %all_parents_postname% : A sanitized version of the title of the post (post slug field on Edit Post/Page panel). So “This Is A Great Post!” becomes this-is-a-great-post in the URI. This Tag contains all the Parent Page Slugs if any parent page is selected before publishing.
  • %category% : A sanitized version of the category name (category slug field on New/Edit Category panel). Nested sub-categories appear as nested directories in the URI.
  • %child-category% : A sanitized version of the category name (category slug field on New/Edit Category panel).
  • %product_cat% : A sanitized version of the product category name (category slug field on New/Edit Category panel). Nested sub-categories appear as nested directories in the URI. This tag is specially used for WooCommerce Products.
  • <%ctax_custom_taxonomy%> : A sanitized version of the custom taxonomy where the taxonomy name is custom_taxonomy. Replace the custom_taxonomy with your appropriate created taxonomy name.
    If you want to provide the default slug which is used when the category/taxonomy doesn\’t be selected so, make sure to provide default name/slug which looks like this: <%ctax_custom_taxonomy??sales%>. Value which is written between the ?? and %> is used as default slug.
  • %author% : A sanitized version of the author name.
  • %author_firstname% : A sanitized version of the author first name. If author first name is not available so, it uses the author\’s username.
  • %author_lastname% : A sanitized version of the author last name. If author last name is not available so, it uses the author\’s username.

Note%postname% is similar as of the %title% tag but the difference is that %postname% can only be set once whereas %title% can be changed. let’s say the title is “This Is A Great Post!” so, it becomes “this-is-a-great-post” in the URI(At the first time, %postname% and %title% works same) but if you edit and change title let’s say “This Is A WordPress Post!” so, %postname% in the URI remains same “this-is-a-great-post” whereas %title% in the URI becomes “this-is-a-wordpress-post”

TAGS FOR TAXONOMIES

  • %name% : Name of the Term/Category. let’s say the name is “External API” so, it becomes external-api in the URI.
  • %term_id% : The unique ID # of the Term/Category, for example 423
  • %slug% : A sanitized version of the name of the Term/Category. So “External API” becomes external-api in the URI.
  • %parent_slug% : A sanitized version of the name of the Term/Category. So “External API” becomes external-api in the URI. This Tag contains Immediate Parent Term/Category Slug if any parent Term/Category is selected before adding it.
  • %all_parents_slug% : A sanitized version of the name of the Term/Category. So “External API” becomes external-api in the URI. This Tag contains all the Parent Term/Category Slug if any parent Term/Category is selected before adding it.

Be warned: This plugin is not a replacement for WordPress’s built-in permalink system. Check your WordPress administration’s “Permalinks” settings page first, to make sure that this doesn’t already meet your needs.

Leave a Comment

4 − 2 =