<section class="post-list-thumbnail-index">
<div class="title">Бесплатные прогнозы на футбол</div>
<?php
global $post;
$args = array( 'posts_per_page' => 10, 'cat' => '-1,-4,-6', 'meta_key' => 'event-date-time', 'orderby' => 'meta_value_num' );
$myposts = get_posts( $args );
$temp_current_date = date('d-m-Y');
//сегодня
foreach( $myposts as $post ):
$temp_event_date = get_field('event-date-time', $post->ID);
$temp = substr($temp_event_date, 0,10);
$current_date = date_create($temp_current_date);
$event_date = date_create($temp);
$interval = date_diff($current_date, $event_date);
if ($interval->format('%R%a') == '+0') :
setup_postdata($post); ?>
<article class="clearfix">
<div class="thumb">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('index-thumb'); ?>
</a>
</div>
<div class="article-text">
<div class="date">
<?php $cat = get_the_category(); ?>
<a href="<?php echo get_category_link($cat[0]->term_id); ?>"><?php echo $cat[0]->name; ?></a> » <?php echo $result; ?>
</div>
<div class="article-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
<div class="text"><?php the_excerpt(); ?></div>
</div>
</article>
<?php else :
continue;
endif;
endforeach;
//вчера
foreach( $myposts as $post ):
$temp_event_date = get_field('event-date-time', $post->ID);
$temp = substr($temp_event_date, 0,10);
$current_date = date_create($temp_current_date);
$event_date = date_create($temp);
$interval = date_diff($current_date, $event_date);
if ($interval->format('%R%a') == '-1') :
setup_postdata($post); ?>
<article class="clearfix">
<div class="thumb">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('index-thumb'); ?>
</a>
</div>
<div class="article-text">
<div class="date">
<?php $cat = get_the_category(); ?>
<a href="<?php echo get_category_link($cat[0]->term_id); ?>"><?php echo $cat[0]->name; ?></a> » <?php echo $result; ?>
</div>
<div class="article-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
<div class="text"><?php the_excerpt(); ?></div>
</div>
</article>
<?php else :
continue;
endif;
endforeach;
//завтра
foreach( $myposts as $post ):
$temp_event_date = get_field('event-date-time', $post->ID);
$temp = substr($temp_event_date, 0,10);
$current_date = date_create($temp_current_date);
$event_date = date_create($temp);
$interval = date_diff($current_date, $event_date);
if ($interval->format('%R%a') == '+1') :
setup_postdata($post); ?>
<article class="clearfix">
<div class="thumb">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('index-thumb'); ?>
</a>
</div>
<div class="article-text">
<div class="date">
<?php $cat = get_the_category(); ?>
<a href="<?php echo get_category_link($cat[0]->term_id); ?>"><?php echo $cat[0]->name; ?></a> » <?php echo $result; ?>
</div>
<div class="article-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
<div class="text"><?php the_excerpt(); ?></div>
</div>
</article>
<?php else :
continue;
endif;
endforeach;
wp_reset_postdata();?>
</section>
pre_get_posts
используйте function search_filter($query) {
if ( ! is_admin() && $query->is_main_query() ) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
}
}
add_action( 'pre_get_posts', 'search_filter' );
$query->set('post_type', 'post');
замените на $query->set('cat', 'ид категории');
add_action('pre_get_posts', 'date_filter');
function date_filter( $query ){
if ( ! is_admin() && $query->is_main_query() && !$query->is_singular() ) {
$args = array (
array(
'after' => array(
'year' => 2016,
'month' => 12,
'day' => 1,
),
),
);
$query->set('date_query', $args);
}
}
<div class="footer" id="id1">
<?php $mwp = get_post( $id ); ?>
<p class="t_text">
<?php echo $mwp->post_title;?>
<?php echo $mwp->post_content;?>
</p>
</div>
'orderby' => array ('name'=>'Footer'),
белиберда)<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
$post_type = get_post_type( $post_id );
if ($post_type=='product') {
global $product;
?>
<div class="quantity">
Количество: <button type="button" id="remove_one">-</button><input type="text" name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" pattern="<?php echo esc_attr( $pattern ); ?>" inputmode="<?php echo esc_attr( $inputmode ); ?>" /><button type="button" id="add_one">+</button>
<div class="order-summ">Сумма: <span id="orderSumm"><?php echo $product->get_price();?></span> грн.</div>
</div>
<script>
var price = jQuery('#orderSumm').html();
var quantity;
var summ;
jQuery('#remove_one').on('click',function(){
quantity = jQuery('input.qty').val();
if (quantity <= 1) {
summ = price*quantity;
jQuery('input.qty').val(quantity);
jQuery('#orderSumm').html(summ);
} else {
quantity--;
summ = price*quantity;
jQuery('input.qty').val(quantity);
jQuery('#orderSumm').html(summ);
}
});
jQuery('#add_one').on('click',function(){
quantity = jQuery('input.qty').val();
quantity++;
summ = price*quantity;
jQuery('input.qty').val(quantity);
jQuery('#orderSumm').html(summ);
});
jQuery('input.qty').keyup(function(){
var removedText = $(this).val().replace(/\D/, '');
jQuery(this).val(removedText);
quantity = jQuery(this).val();
summ = price*quantity;
jQuery('input.qty').val(quantity);
jQuery('#orderSumm').html(summ);
});
</script>
<?php } else {?>
<div class="quantity">
<input type="number" step="<?php echo esc_attr( $step ); ?>" min="<?php echo esc_attr( $min_value ); ?>" max="<?php echo esc_attr( $max_value ); ?>" name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" pattern="<?php echo esc_attr( $pattern ); ?>" inputmode="<?php echo esc_attr( $inputmode ); ?>" />
</div>
<?php }?>
get_the_terms( $product->id, 'pa_color');
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
if ( is_user_logged_in() ) {
unset( $tabs['additional_information'] );
}
return $tabs;
}
<?php $names = array ('один атрибут', 'второй атрибут') //имена атрибутов, которые не будем показывать
foreach ( $attributes as $attribute ) :
if ( !is_user_logged_in() && in_array($attribute['name'], $names ) {
continue; //пропускаем атрибут
}
if ( empty( $attribute['is_visible'] ) || ( $attribute['is_taxonomy'] && ! taxonomy_exists( $attribute['name'] ) ) ) {
continue;
} else {
$has_row = true;
}
?>
<tr class="<?php if ( ( $alt = $alt * -1 ) == 1 ) echo 'alt'; ?>">
<th><?php echo wc_attribute_label( $attribute['name'] ); ?></th>
//далее остальной файл
add_action( 'after_setup_theme', 'mytheme_setup' );
function mytheme_setup() {
add_theme_support( 'menus' );
}
wp_nav_menu()
<?php
wp_nav_menu( array(
'menu' => 'название_меню',
'container' => 'nav', // ну или div
'container_class' => 'класс контейнера',
) );
?>
Решение данной проблемы простое, необходимо в файл wp-config.php дописать в самый конец строку:
define('FS_METHOD', 'direct');
Либо более «правильный» код:
if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}
После чего WordPress должен обновляться в нормальном режиме.
is_user_logged_in( )
и, в зависимости от результата, выводите разный набор ссылок войти/выйти. Например, echo wp_logout_url( )
выведет ссылку на выход. Остальное тоже можно нагуглить. А вот кабинет/профиль вроде в WP базовом нет, сразу админка. <ul id="slider">
<?php
foreach ( $attachment_ids as $at_id ) { ?>
<li id="<?php echo $at_id?>">
<img src="<?php echo wp_get_attachment_link($at_id,'full');?>">
</li>
<?php } ?>
</ul>
<ul id="thumb">
<?php
foreach ( $attachment_ids as $at_id ) { ?>
<li>
<a href="#<?php echo $at_id?>">
<img src="<?php echo wp_get_attachment_link($at_id,'thumbnail');?>">
</a>
</li>
<?php } ?>
</ul>
Может кто подскажет, где я туплю.
have_posts($post_id)
- вот это вообще откуда? и вот это the_post($post_id)
get_the_category();
нужно передавать ID поста. По умолчанию используется ID текущего поста в цикле.next_post_link
и previous_post_link
Используются только на страницах единичной записи. Любые функции пагинации и навигации работают только с основным запросом (global $wp_query).showposts
устарело, используйте posts_per_page