wordpress - Single Taxonomy Attached to Multiple Post Types Template Question -


so have site 6 custom post types.three of these post types attached single custom taxonomy.

i able list_cats in sidebar , spit out url ../%post_type%/%taxonomy%/ , have take taxonomy-%taxonomy%.php template , return results of %post_type%.

i can create conditional read current %post_type% , style correctly once in taxonomy-%taxonomy%.php file. need direction on effective method modify url pass %post_type% query.

thanks in advance. have searched couple days no clear answer.

so here feeble attempts @ solution yet 1 big fail based off discussion found @ rlmseo.com ant answer here.

trying add post type variable use in query:

practice-areas taxonomy. trying add variable can use filter taxonomy post type in taxonomy-practice-areas.php

function add_query_vars($avars) {     $avars[] = "cust_pt_var";    // represents name of custom post type shown in url     return $avars; }  // hook add_query_vars function query_vars add_filter('query_vars', 'add_query_vars');        function add_rewrite_rules($arules) {     $anewrules = array('practice-areas/([^/]+)/pt/([^/]+)/?$' => 'index.php?practice-areas=$matches[1]&cust_pt_var=$matches[2]');     $arules = $anewrules + $arules;     return $arules; }  // hook add_rewrite_rules function rewrite_rules_array add_filter('rewrite_rules_array', 'add_rewrite_rules') 

trying pass query variables in rewrite

trying add post types (portfolio & clients) practice-areas taxonomy term query @ rewrite.

function add_rewrite_rules($arules) {     $anewrules = array('portfolio/practice-areas/([^/]+)/?$' => 'index.php?post_type=portfolio&practice-areas=$matches[1]');     $anewrules = array('clients/practice-areas/([^/]+)/?$' => 'index.php?post_type=clients&practice-areas=$matches[1]');     $arules = $anewrules + $arules;     return $arules; }  // hook add_rewrite_rules function rewrite_rules_array add_filter('rewrite_rules_array', 'add_rewrite_rules') 

you should able accomplish modifying wp's rewrite rules:

add_action( 'init', 'ss_permalinks' ); function ss_permalinks() {     add_rewrite_rule(         'page/remove/([^/]+)/?',         'index.php?pagename=page&service=$matches[1]',         'top' ); } add_filter( 'query_vars', 'ss_query_vars' ); function ss_query_vars( $query_vars ) {     $query_vars[] = 'removeid';     return $query_vars; } 

this incomplete , you'll need change target url , rule itself, basis. re-save permalink settings once after implementing. page slug of page point when user access url (in case domain.com/page/remove/432), , $matches[1] should number after remove/ in url. number accessible variable specified later, $query_vars[] = 'removeid'; / '$removeid' on target page's template number in url, if specified.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -