Documentation / Tutorials / Awesome Enterprise

Add term in the post URL

/ Awesome Enterprise / Add term in the post URL

If we want to add the taxonomy in the URL then need to add a rewrite rule in the site_specific.php

Reference:
Base: /aw-enterprise/
file: includes/app_setup.php
function: controller_taxonomy

This function checks multiple possibilities:
1. Checks for the meta with the key “default_taxonomy” defined in the App > Config > settings. If it is not present then it returns from the function and calls to render the post-single-layout.
2. Checks for the “default_taxonomy” with the value and it present then will check it with the wp function term_exists(). If term present in the DB will call archive-layout
3. If the term present and assigned to the post as well then it will call archive.
4. Term present in the URL and rewrite rule added then code will not check is it assigned or not with to the post. It will directly get rendered because rewrite rule is only looking for the post name. [See the rewrite to know more]

Add this code in the site-specific.php

URL: app/{postname} to app/{term}/{postname}

[Note: This will load the archive-layout instead of the post-layout if the post term and default_taxonomy term slug are same.]

 

 

This code will rewrite URL for the followings:
1. Post URL
2. Default permalink URL in the Yoast sitemap
3. Canonical URL
4. Filters all the http:// URLs in Yoast sitemap and changes to https://

Categories
Most Popular

Leave a Reply

Your email address will not be published.