<?php
/*
Template Name: Simple post 2 Loop page
*/
?>
<?php get_header(); ?>
<?php
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) { // 'page' is used instead of 'paged' on Static Front Page
$paged = get_query_var('page');
} else {
$paged = 1;
}
$custom_query_args = array(
'post_type' => 'post',
'posts_per_page' => get_option('posts_per_page'),
'paged' => $paged,
'post_status' => 'publish',
'ignore_sticky_posts' => true,
//'category_name' => 'custom-cat',
'order' => 'DESC', // 'ASC'
'orderby' => 'date' // modified | title | name | ID | rand
);
$custom_query = new WP_Query( $custom_query_args );
if ( $custom_query->have_posts() ) :
while( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
<article <?php post_class(); ?>>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<div><?php the_excerpt(); ?></div>
</article>
<?php
endwhile;
?>
<?php if ($custom_query->max_num_pages > 1) : // custom pagination ?>
<?php
$orig_query = $wp_query; // fix for pagination to work
$wp_query = $custom_query;
?>
<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; // fix for pagination to work
?>
<?php endif; ?>
<?php
wp_reset_postdata(); // reset the query
else:
echo '<p>'.__('Sorry, no posts matched your criteria.').'</p>';
endif;
?>
<?php get_footer(); ?>
$wp_query -> query('v_sortby=views&v_orderby=desc&posts_per_page=10&what_to_show=posts&post_status=publish'.'&paged='.$paged);
$wp_query = new WP_Query(
array_merge(
array(
'date_query' => array(
'before' => array( 'year' => 2018, 'month' => 7, 'day' => 25 ),
'after' => array( 'year' => 2018, 'month' => 7, 'day' => 25 ),
'inclusive' => true
)
),
$wp_query->query
)
);
<?php
/*
* Template Name: CF7DB
*/
get_header();
$fid = 2945; // номер формы
$data = array();
$prev = 0;
// получаем список сохраненных полей
$fields = vsz_cf7_get_db_fields($fid, false);
// получаем все данные сохраненные из формы
// сюда еще фильтр нужно для пагинации или просто ограничения
$query = "SELECT * FROM `".VSZ_CF7_DATA_ENTRY_TABLE_NAME."` WHERE `cf7_id` = ".$fid." ORDER BY `data_id` DESC";
$result = $wpdb->get_results($query);
// формируем массив $data со списком данных, разворачивая из линейного в массив
$one = array();
foreach($result as $row)
{
if ($prev != 0 && $row->data_id != $prev)
{
$data[] = $one;
$one = array();
}
foreach($fields as $field)
{
if ($row->name == $field)
$one[$field] = $row->value;
}
$prev = $row->data_id;
}
$data[] = $one;
// если есть какие либо данные выводим в простую таблицу для отображения
if (count($data))
{
echo '<table>';
echo "<tr>";
foreach($fields as $field)
{
echo '<td style="padding:5px">';
echo "<strong>", $field, "</strong>";
echo "</td>";
}
echo "</tr>";
foreach($data as $d)
{
echo "<tr>";
foreach($fields as $field)
{
echo '<td style="padding:5px">';
echo $d[$field];
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
}
get_footer();
<?php
require_once 'phpQuery-onefile.php';
$html = file_get_contents ('http://www.pesmaster.com/spanish-league/pes-2019/league/11/');
$pq = phpQuery::newDocument($html);
$cl = $pq->find("a.namelink[href*='team']");
foreach ($cl as $link)
{
$href[] = pq($link)->attr("href");
}
foreach ($href as $i)
{
echo $i;
echo "<br/>";
}
phpQuery::unloadDocuments($pq);
<?php
if (empty($wp)) {
require_once('[путь к WP]wp-config.php');
}
global $wpdb;
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts LIMIT 2");
echo "<pre>";
print_r($posts);
// или можно использовать WP_Query()
PUM.open([номер попапки])
echo '<div class="dictionary-block"><div class="padding-block">';
foreach( $posts as $k => $post ){
setup_postdata($post);
$fl = get_first_letter( $post->post_title );
if( $prev_fl !== $fl ){
if (isset($prev_fl))
echo "</ul>";
echo '<b>'.$fl.'</b><ul class="dictionary-list">';
}
echo '<li><strong>' . get_the_title() . '</strong><p>' . the_field("desc") . '</p><a href="' . the_field("url") . '" class="link">Подробнее</a></li>';
$prev_fl = $fl;
}
if (isset($prev_fl))
echo "</ul>";
echo '</div></div>';