Tag Info

New answers tagged

0

You can always check the value of the result with the function var_dump as follows: var_dump( $matches[1] ); In this case, I think is returning an Array with the results you should try to out. <?php echo $matches[1][0] ; ?>


0

Try adding 'source' as an custom query var, rather than defining it as a rewrite tag. function wpse162627_add_query_vars( $query_vars ){ $query_vars[] = "source"; return $vars; } add_filter( 'query_vars', 'wpse162627_add_query_vars' ); function custom_url_source() { add_rewrite_rule( '^source/([^/]*)$', ...


1

Rather than add a rule to .htaccess, you can use a WordPress rewrite to do this: function cdl_rewrite_rule(){ add_rewrite_rule( 'cdl-manual/([-a-z]+)/?$', 'index.php?pagename=cdl-manual&jp_stn=$matches[1]', 'top' ); } add_action( 'init', 'cdl_rewrite_rule' ); This is assuming you've already added jp_stn to the list of ...


0

The reason you are getting a 404 is that the rewrite rule do not change the request URL as reported sin $_SERVER[REQUEST_URI] variable of PHP, and wordpress parses that variable when deciding what content is request and since there is no such page /cdl-manual/arizona/ it displays a 404. What you need is a wordpress rewrite rule to parse the url the way you ...


0

What you want and what you need is two sites with content duplication, probably under a multisite install. While you still need to write some duplication code it is a much easier to develop and debug and is low on dragons.


2

The third parameter tells WordPress what query variable(s) to use/match. We can query our WordPress database with those public query variables, via requests like example.com/?foo1=bar1&foo2=bar2 but we usually want to rewrite it to something more pretty, like example.com/bar1/bar2/. In the Codex there's a list of the default available public query ...


0

I think I found a solution to this with a function that's not commonly used: add_permastruct(). This does the trick of what I described above: add_rewrite_tag('%page%','([^/]+)', 'pagename='); add_permastruct('abc','/abc/%page%/',false); add_rewrite_rule('abc/?$','index.php?page_id=6','top'); The add_rewrite_tag() defines the pagename value that I want ...


3

Have you tried: The main one: add_rewrite_rule( 'region/([^/]+)/type/([^/]+)/?', 'index.php?taxonomy=region&term=$matches[1]&post_type=$matches[2]', 'top' ); For pagination add_rewrite_rule( 'region/([^/]+)/type/([^/]+)/page/([0-9]{1,})/?', 'index.php?taxonomy=region&term=$matches[1]&post_type=$matches[2]&paged=$matches[3]', 'top' ); ...


0

This answer helped me thru a custom rewrite issue. I want to add that my case was a bit different in that I nested the category tree within the url structure example.com/brand-list/brand-child-category/brand-grand-child-category/page/1 This would be like brand-list/nike/air-jordans/high-tops/postname To get mine to work I had 1 call for the categories, ...


9

When you visit a fronted page WordPress will query database, and if your pages does not exists in database, that query is not needed and is just a waste of resource. Luckily WordPress offers a way to handle frontend requests in a custom way. That is done thanks to the 'do_parse_request' filter. Returing false on that hook you will be able to stop ...


0

I once used a solution described here: http://scott.sherrillmix.com/blog/blogger/creating-a-better-fake-post-with-a-wordpress-plugin/ Actually, when I was using it, I extend the solution in a way I can register more than one page a time (the rest of a code is +/- similar to the solution I'm linking from a paragraph above). The solution requires you to have ...



Top 50 recent answers are included