function do_rewrite(){
// Правило перезаписи
$ref_p="названиестраницы";
//p_id = 88 - id страницы названиестраницы
add_rewrite_rule( '^' . $ref_p . '/([^/]*)/([^/]*)/?', 'index.php?p=88¶m1=$matches[1]¶m2=$matches[2]', 'top' );
add_filter( 'query_vars', function( $vars ){
$vars[] = 'param1';
$vars[] = 'param2';
return $vars;
} );
}
add_action('init', 'do_rewrite');`
<?php
function my_shortcode( $atts ) {
extract( shortcode_atts(
array(
'slug' => '',
), $atts )
);
$out ='';
$query = new WP_Query('category_name=' . $slug);
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$out .= '<div><h3 >' . get_the_title() . '</h3>' . get_the_content() . '</div>';
}
} else {
$out .= 'Записей для вывода шорткодом нет';
}
wp_reset_query();
return $out;
}
add_shortcode( 'category ', 'my_shortcode' );
$post_author = ( is_singular() ) ? get_post()->post_author : 0;
// в админке осталяем как было
if( ! is_admin() ) {
//переопределяем загрузку ядра
wp_deregister_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-core', site_url( '/wp-includes/js/jquery/ui/core.min.js' ), array('jquery') );
//переопределяем загрузку api виджетов
wp_deregister_script( 'jquery-ui-widget' );
wp_enqueue_script( 'jquery-ui-widget', site_url( '/wp-includes/js/jquery/ui/widget.min.js' ), array('jquery') );
// табы
wp_deregister_script( 'jquery-ui-tabs' );
wp_enqueue_script( 'jquery-ui-tabs', site_url( '/wp-includes/js/jquery/ui/tabs.min.js' ), array('jquery') );
//диалог
wp_deregister_script( 'jquery-ui-dialog' );
wp_enqueue_script( 'jquery-ui-dialog', site_url( '/wp-includes/js/jquery/ui/dialog.min.js' ), array('jquery') );
}
add_action( 'woocommerce_product_after_variable_attributes', 'cr_variable_fields', 10, 3 );
add_action( 'woocommerce_product_after_variable_attributes_js', 'cr_variable_fields_js' );
add_action( 'woocommerce_process_product_meta_variable', 'save_cr_variable_fields', 10, 1 );
/**
* Создает новое поле
*/
function cr_variable_fields( $loop, $variation_data, $variation ) {
?>
<tr>
<td>
<?php
woocommerce_wp_text_input(
array(
'id' => '_text_field['.$loop.']',
'label' => __( 'Мое текстовое поле', 'woocommerce' ),
'placeholder' => __( 'Подсказка', 'woocommerce' ),
'desc_tip' => 'true',
'description' => __( 'Введите ваше значение.', 'woocommerce' ),
'value' => get_post_meta( $variation->ID, '_text_field', true )
)
);
?>
</td>
</tr>
<?php
}
/**
* Создает поле нового варианта
*/
function cr_variable_fields_js() {
?>
<tr>
<td>
<?php
woocommerce_wp_text_input(
array(
'id' => '_text_field[ + loop + ]',
'label' => __( 'Мое текстовое поле', 'woocommerce' ),
'placeholder' => __( 'Подсказка', 'woocommerce' ),
'desc_tip' => 'true',
'description' => __( 'Введите ваше значение.', 'woocommerce' ),
'value' => ''
)
);
?>
</td>
</tr>
<?php
}
/**
* Сохраняет поле
*/
function save_cr_variable_fields( $post_id ) {
if (isset( $_POST['variable_sku'] ) ) :
$variable_sku = $_POST['variable_sku'];
$variable_post_id = $_POST['variable_post_id'];
$_text_field = $_POST['_text_field'];
for ( $i = 0; $i < sizeof( $variable_sku ); $i++ ) :
$variation_id = (int) $variable_post_id[$i];
if ( isset( $_text_field[$i] ) ) {
update_post_meta( $variation_id, '_text_field', stripslashes( $_text_field[$i] ) );
}
endfor;
endif;
}
add_action('woocommerce_shop_loop_item_title' ,'woocommerce_template_single_excerpt',20);
<article id="post-<?php echo $post->ID; ?>" <?php post_class(); ?>>
// содержимое записи
</article>
article.category-foo:before {
width: 30px;
height: 30px;
content: ' ';
background-image: url('%img-url%');
display: block;
position: absolute;
top: -25px;
left: -25px;
}
add_filter('sanitize_file_name', '%ваша функция транслитерации%');
$args = unserialize(stripslashes($_POST['query']));
$args['paged'] = $_POST['page'] + 1; // следующая страница
$args['post_status'] = 'publish';
$first_page_post_count = 9;
$empty_pages_post_count = 8;
if ($args['paged'] > 1) {
$posts_per_page = $empty_pages_post_count;
if ($args['paged'] == 2) {
$offset = $first_page_post_count;
} else {
$offset = $first_page_post_count + ( $empty_pages_post_count * ($args['paged'] - 2));
}
} else {
$offset = 0;
$posts_per_page = $first_page_post_count;
}
$args['posts_per_page'] =>$posts_per_page;
$args['offset'] => $offset;
$q = new WP_Query($args);
register_activation_hook(__FILE__, 'activate_options');
add_options_page('RDolls Category Adder', 'RDolls Category Setting', 8, __FILE__, 'plugin_setting_page');
add_options_page('RDolls Category Adder', 'RDolls Category Setting', 'manage_options', __FILE__, 'plugin_setting_page');
<?php
$attachment_id = 8; // attachment ID
$image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array
if( $image_attributes ) {
?>
<img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>">
<?php } ?>