add_shortcode( 'my', 'my_shortcode' );
function my_shortcode() {
ob_start();
?> <script>/* js-код */</script> <?php
return ob_get_clean();
}
$translate['big_string'] = __('A string', 'translation_name');
$translate['very_big_string'] = __('A string', 'translation_name');
$translate['very_very_big_string'] = __('A big string', 'translation_name');
function my_js_variables() { ?>
<script type="text/javascript">
var templateUrl = '<?php get_template_directory_uri(); ?>';
</script><?php
}
add_action ( 'wp_head', 'my_js_variables' )
$translation_array = array( 'templateUrl' => get_stylesheet_directory_uri() );
wp_localize_script( 'my-script', 'themename', $translation_array );
var templateUrl = themename.templateUrl;
$terms = get_terms( array(
'taxonomy' => 'category',
'parent' => '10',
'hide_empty' => false
) );
Количество постов должно быть в $term->count.