<meta name="robots" content="noindex, nofollow" />
<?php
/**
* @Redirect attachment to your homepage
* @package WordPress
*/
wp_redirect(home_url());
exit;
?>
// initial hook
add_action( 'save_post', 'prefix_save_post_callback' );
function prefix_save_post_callback( $post_id ) {
// verify post is not a revision
if ( ! wp_is_post_revision( $post_id ) ) {
// unhook this function to prevent infinite looping
remove_action( 'save_post', 'prefix_save_post_callback' );
// update the post slug
wp_update_post( array(
'ID' => $post_id,
'post_name' => 'some-new-slug' // do your thing here
));
// re-hook this function
add_action( 'save_post', 'prefix_save_post_callback' );
}
}
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
add_action('wp_enqueue_scripts', function(){
wp_enqueue_script( 'prefix_slick', get_stylesheet_directory_uri() .'/js/slick.min.js' );
// добавим произвольный код
if ( is_front_page() ) {
wp_add_inline_script( 'prefix_slick', '$(document).ready(function(){ $(".your-class").slick({ setting-name: setting-value }); });' );
} else if ( is_page_template( $template ) ) {
wp_add_inline_script( 'prefix_slick', '' );
}
});
<script type='text/javascript' src='http://site.ru/wp-content/themes/mytheme/js/slick.min.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
$('.your-class').slick({
setting-name: setting-value
});
});
</script>
<?php echo get_post_meta($post->ID, 'price', true); ?>
<?php echo do_shortcode('[price]'); ?>
[price]
<?php echo round(get_post_meta($post->ID, 'price', true) / 40044, 5); ?>
<?php echo do_shortcode('[btc]'); ?>
[btc]
// часовой пояс Москва
$main_timezone = get_option( 'timezone_string', 'Europe/Moscow' );
date_default_timezone_set( "$main_timezone" );
// для даты создания
function main_get_the_date($the_date, $d, $post) {
$d = 'd.m.Y';
$date_now = date_format(date_create("now"), $d);
$date_yesterday = date_format(date_create("yesterday"), $d);
$post = get_post($post);
if ( !$post ) {
return $the_date;
}
$the_date = mysql2date( $d, $post->post_date);
if ($date_now == $the_date) {
$the_date = esc_html__( 'сегодня', 'main' );
} elseif ($date_yesterday == $the_date) {
$the_date = esc_html__( 'вчера', 'main' );
}
return $the_date;
}
add_filter( 'get_the_date', 'main_get_the_date', 10, 3 );
// для даты изменения
function main_get_the_modified_date($the_time, $d) {
$d = 'd.m.Y';
$date_now = date_format(date_create("now"), $d);
$date_yesterday = date_format(date_create("yesterday"), $d);
$the_time = get_post_modified_time($d, null, null, true);
if ($date_now == $the_time) {
$the_time = esc_html__( 'сегодня', 'main' );
} elseif ($date_yesterday == $the_time) {
$the_time = esc_html__( 'вчера', 'main' );
}
return $the_time;
}
add_filter( 'get_the_modified_date', 'main_get_the_modified_date', 10, 2 );
<?php
/**
* Search form
*/
?>
<form role="search" method="get" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<p><input type="search" id="searchfield" class="searchfield" name="s" placeholder="<?php esc_html_e( 'Search', 'main' ); ?>…" value="<?php echo get_search_query() ?>" required /></p>
<p><input type="submit" id="searchsubmit" class="searchsubmit" value="<?php esc_html_e( 'Find', 'main' ); ?>"></p>
</form>
[your-file][your-another-file]
/home/you/dir/dir/dir/fantasticpicture.jpg
uploads/2013/08/08/boringguide.pdf
add_action('init', function() {
$GLOBALS['wp_rewrite']->author_base = '';
}, 1);