add_filter( 'events_group_rewrite_rules', 'namespace_events_group_rewrite_rules' );
function namespace_events_group_rewrite_rules( array $rules ): array {
$terms = get_terms(
[
'taxonomy' => 'events_group',
'hide_empty' => false,
]
);
$slugs = wp_list_pluck( $terms, 'slug' );
$slugs_pattern = '(' . implode( '|', array_unique( $slugs ) ) . ')';
$new_rules = [];
foreach ( $rules as $pattern => $query ) {
$pattern = str_replace( 'events_group/([^/]+)', $slugs_pattern, $pattern );
$new_rules[ $pattern ] = $query;
}
return $new_rules;
}
add_filter( 'term_link', 'namespace_events_group_term_link', 10, 3 );
function namespace_events_group_term_link( string $termlink, \WP_Term $term, string $taxonomy ): string {
if ( 'events_group' === $taxonomy ) {
$termlink = str_replace( 'events_group/', '', $termlink );
}
return $termlink;
}
function add_custom_rewrite_rule() {
if( ($current_rules = get_option('rewrite_rules')) ) {
foreach($current_rules as $key => $val) {
if(strpos($key, 'event') !== false) {
add_rewrite_rule(str_ireplace('event', 'events', $key), $val, 'top');
} // end if
} // end foreach
} // end if/else
//flush_rewrite_rules();
} // end add_custom_rewrite_rule
add_action('init', 'add_custom_rewrite_rule');
function na_remove_slug( $post_link, $post, $leavename ) {
if ( 'event' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/events/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'na_remove_slug', 10, 3 );
add_action( 'template_redirect', function() {
if( is_singular( 'event' ) ){
global $post;
if ( $_SERVER['REQUEST_URI'] == '/event/'.$post->post_name) {
wp_redirect( home_url('/events/'.$post->post_name), 301 );
exit();
}
}
} );
.box {
transform: skewX(10deg);
}
.box > * {
transform: skewX(-10deg);
}
<?php $services = get_field( 'services' ); ?>
<div class="service-features-nav">
<?php
$prev_post = get_adjacent_post(0, '', 0);
if( $prev_post && get_field('services', $prev_post->ID) == $services)
echo '<span class="nav-previous">← <a href="'. get_permalink($prev_post->ID) .'">'. $prev_post->post_title .'</a></span>';
$next_post = get_adjacent_post();
if( $next_post && get_field('services', $next_post->ID) == $services)
echo '<span class="nav-next"><a href="'. get_permalink($next_post->ID) .'">'. $next_post->post_title .'</a> →</span>';
?>
</div>
<?php
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
global $post;
global $wpdb;
?>
<?php $markers = get_posts ('post_type=markers&order=ASC'); ?>
<?php $arr = array(); ?>
<?php if ($markers) :?>
<?php foreach ($markers as $post) : setup_postdata ($post); ?>
<?php
$arr[get_the_ID()]['type'] = 'Feature';
$arr[get_the_ID()]['id'] = '0';
$arr[get_the_ID()]['geometry']['type'] = 'Point';
$arr[get_the_ID()]['geometry']['coordinates'] = array(55.831903, 37.411961);
$arr[get_the_ID()]['properties']['balloonContent'] = 'Содержимое балуна';
$arr[get_the_ID()]['properties']['clusterCaption'] = 'Еще одна метка';
$arr[get_the_ID()]['properties']['hintContent'] = 'Текст подсказки';
?>
<?php endforeach; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<?php
$array = array(
"type" => "FeatureCollection",
"features" => array_values($arr)
);
?>
<?php echo json_encode($array); ?>