$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'operator' => 'NOT EXISTS',
)
)
);
$query = new WP_Query( $args );
foreach($query->query() as $post){
wp_delete_post($post->ID);
}
...
<?php endwhile; ?>
<?php if ($recent->max_num_pages > 1) : // custom pagination ?>
<?php
$orig_query = $wp_query;
$wp_query = $recent;
?>
<nav class="prev-next-posts">
<div class="prev-posts-link">
<?php echo get_next_posts_link( 'Older Entries', $custom_query->max_num_pages ); ?>
</div>
<div class="next-posts-link">
<?php echo get_previous_posts_link( 'Newer Entries' ); ?>
</div>
</nav>
<?php
$wp_query = $orig_query;
?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
...
<?php
/*
* Template Name: ACF data table
*/
?>
<?php get_header(); ?>
<?php
$the_query = new WP_Query( array(
'posts_per_page' => 20,
'post_type' => 'post'
) );
if( $the_query->have_posts() ) :
while( $the_query->have_posts() ): $the_query->the_post();
if (get_field('fio',$post->ID) != "")
echo get_field('fio',$post->ID) . ", " . get_field('date',$post->ID) . "<br>";
endwhile;
wp_reset_postdata();
endif;
?>
<?php get_footer(); ?>
<?php
if (empty($wp)) {
require_once('wp-config.php');
}
global $wpdb;
$posts = $wpdb->get_results(
"SELECT
p.ID, p.post_name
FROM
wp_posts p
WHERE
p.post_type = 'post' AND p.post_status = 'publish'");
$double = array();
$rewrite = array();
foreach($posts as $post){
if (!array_key_exists($post->post_name,$double)){
$double[$post->post_name] = 0;
}else{
$double[$post->post_name] += 1;
$rewrite[$post->ID] = $post->post_name . "-" . $double[$post->post_name];
}
}
foreach($rewrite as $key => $value){
$wpdb->update( 'wp_posts',
array( 'post_name' => $value ),
array( 'ID' => $key )
);
}