WordPress
3
Вклад в тег
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();
}
}
} );
<?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); ?>
.box {
transform: skewX(10deg);
}
.box > * {
transform: skewX(-10deg);
}