Skip to content

Instantly share code, notes, and snippets.

@VicVicos
Created December 12, 2017 06:13
Show Gist options
  • Select an option

  • Save VicVicos/3e0ed28983062f838556a991a66cea74 to your computer and use it in GitHub Desktop.

Select an option

Save VicVicos/3e0ed28983062f838556a991a66cea74 to your computer and use it in GitHub Desktop.
Rewrite rule url for custom post type WP and other...
<?php
class CFunctions
{
public function __construct ()
{
add_action('init', [$this, 'rewrite_rule_cpost']);
}
public function rewrite_rule_cpost()
{
$post_type = 'avada_portfolio';
add_rewrite_tag( "%avada_portfolio%", '([^/]+)', "post_type=$post_type&name=" );
$permastruct = "nefteprodukty/%avada_portfolio%"; // наша структура ЧПУ
$args = array(
'with_front' => true,
'paged' => true,
'ep_mask' => EP_NONE,
'feed' => false,
'forcomments' => false,
'walk_dirs' => false,
'endpoints' => false,
);
add_permastruct( $post_type, $permastruct, $args );
}
}
new CFunctions();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment