Answer the question
In order to leave comments, you need to log in
How to create a page template for a page template in WordPress?
I can't seem to get pagination in WP. The standard functions posts_nav_link() and the_posts_navigation() only work for me in my theme's index.php file. But my posts should be displayed on a separate page in the page-news.php template. Records are displayed on it, but pagination cannot be done in any way. I searched the Internet for custom functions for creating pagination, but they also don’t work for me, and it’s not enough to write my own, because. I am new to WP and generally new to back-end development. I will be glad for any help.
<?php get_header(); ?>
<main>
<div class="main-content">
<h1>Новости</h1>
<?php
global $post;
$args = array( 'numberposts' => 4 , 'category' => 1, 'orderby' => 'date');
$myposts = get_posts( $args );
foreach( $myposts as $post ){ setup_postdata($post);
?>
<div class="articles">
<div class="articles-gen-img">
<a href="<?php the_permalink(); ?>">
<?php if(has_post_thumbnail()): ?>
<?php the_post_thumbnail(); ?>
<?php else: ?>
<img src="<?php bloginfo('template_url'); ?>/img/no_img.jpg">
<?php endif; ?>
</a>
</div>
<div class="articles-head">
<span class="articles-date"><img src="<?php bloginfo('template_url'); ?>/img/articles-autor.jpg" alt="admin" /> <span><?php the_author(); ?></span> - <?php the_time('j F Y в H:i'); ?></span>
<span class="articles-comments"><img src="<?php bloginfo('template_url'); ?>/img/articles-comment.jpg" alt="commets" /> <a href="#"><?php comments_popup_link('Нет комментариев', '1 комментарий', '%1$s комментариев', '', 'Комментирование отключено'); ?></a></span>
</div>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php the_excerpt(); ?>
<p><a href="<?php the_permalink(); ?>">Читать дальше...</a></p>
</div>
<?php
}
wp_reset_postdata();
?>
<div class="pager">
<?php if (function_exists('wp_corenavi')) wp_corenavi(); ?>
</div>
</div>
<?php get_sidebar(); ?>
</main>
<?php get_footer(); ?>
</div>
<?php wp_footer(); ?>
</body>
</html>
<?php
/**
* Загружаемые скрипты и стили
*/
function load_style_script(){
wp_enqueue_style('style', get_template_directory_uri() . '/style.css');
wp_enqueue_style('font-awesome', get_template_directory_uri() . '/css/font-awesome.css');
wp_register_style('font-style', 'https://fonts.googleapis.com/css?family=Old+Standard+TT:400,700|Roboto:400,500,700&subset=cyrillic');
wp_enqueue_style('font-style');
}
/**
* Загружаем скрипты и стили
*/
add_action('wp_enqueue_scripts', 'load_style_script');
/**
* Длина обрезвемого текста поста (в словах)
*/
add_filter( 'excerpt_length', function(){
return 40;
} );
/**
* Поддержка миниатюр
*/
add_theme_support('post-thumbnails');
set_post_thumbnail_size(180,180);
/**
* Пагенация
*/
function wp_corenavi(){
global $wp_query;
$pages = '';
$max = $wp_query->max_num_pages;
if (!$current = get_query_var('paged')) $current = 1;
$a['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999));
$a['total'] = $max;
$a['current'] = $current;
$total = 1; //1 - выводить текст "Страница N из N", 0 - не выводить
$a['mid_size'] = 3; //сколько ссылок показывать слева и справа от текущей
$a['end_size'] = 1; //сколько ссылок показывать в начале и в конце
$a['prev_text'] = '«'; //текст ссылки "Предыдущая страница"
$a['next_text'] = '»'; //текст ссылки "Следующая страница"
if ($max > 1) echo '<div class="navigation">';
if ($total == 1 && $max > 1) $pages = '<span class="pages">Страница ' . $current . ' из ' . $max . '</span>'."\r\n";
echo $pages . paginate_links($a);
if ($max > 1) echo '</div>';
}
?>
Answer the question
In order to leave comments, you need to log in
Simple solution - dimox.name/wordpress-pagination-without-a-plugin Implementation
example -
https://md7.info/surgery
https://reporter.by/belarus
Better use query_posts or WP_Query cycles
And you didn't separate the template into footer .php & header.php ? As I see you have wp_footer() in the same template where it is called...
Ready working code:
Add to functions:
function wp_corenavi(){
global $wp_query;
$pages = '';
$max = $wp_query->max_num_pages;
if (!$current = get_query_var('paged')) $current = 1;
$a['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999));
$a['total'] = $max;
$a['current'] = $current;
$total = 1; //1 - выводить текст "Страница N из N", 0 - не выводить
$a['mid_size'] = 3; //сколько ссылок показывать слева и справа от текущей
$a['end_size'] = 1; //сколько ссылок показывать в начале и в конце
$a['prev_text'] = '«'; //текст ссылки "Предыдущая страница"
$a['next_text'] = '»'; //текст ссылки "Следующая страница"
if ($max > 1) echo '<div class="navigation">';
if ($total == 1 && $max > 1) $pages = '<span class="pages">Страница ' . $current . ' из ' . $max . '</span>'."\r\n";
echo $pages . paginate_links($a);
if ($max > 1) echo '</div>';
}
/* pagination */
.navigation {
display: block;
text-align: center;
margin: 20px auto;
}
.pages {
padding: 5px 7px;
color: #fff;
background: #333;
}
.page-numbers {
background: #333;
padding: 5px 7px;
color: #fff !important;
}
.page-numbers.current {
text-decoration: underline;
}
.page-numbers:hover {
text-decoration:none;
opacity: 0.8;
}
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<? //здесь ваш контент ?>
<?php endwhile; ?>
<?php if (function_exists('wp_corenavi')) wp_corenavi(); ?>
<?php endif; ?>
https://github.com/talentedaamer/Bootstrap-wordpre...
Here is a great pagination solution. Works perfectly and is very configurable.
Definitely either "Applied Mathematics and Informatics" or "Software Engineering".
Just do not forget that in addition to this, you still have to develop a lot on your own if you want to become a programmer.
Everyone here answers, but no one wrote that the program can differ quite a lot from university to university in the same specialties. Therefore, look at the curricula of each of these specialties and choose the one where there are more subjects that are useful to you.
It is theoretically possible that in some university you will be taught to program better in the faculty of business informatics (which of all the specialties you listed least relates to programming) than in any other university in software engineering.
And if you look at the general case, then in software engineering there should be most of all programming.
It also depends on the teachers. Try to find out about the teachers in the universities in question.
And I, perhaps, will vote for "01.03.02 - Applied Mathematics and Informatics" .
Mathematics gives a lot in understanding algorithmization. And you are unlikely to get real working knowledge at the university anyway. The task of the university is to give a push to ensure that a person develops independently and to give the basics. I sincerely advise, as early as possible (for example, by the third year, when more specialized subjects begin) to find a part-time job in your specialty. When you see the reflection of the acquired knowledge in real practice (and not in the laboratory) - the information will begin to be assimilated much faster.
02.03.02 - Fundamental informatics and information technologies
Xs, what will they give. Look for alumni. Look at their profiles where they work. The title is too broad.
Discrete, database and websites will be taught. Technology depends purely on the knowledge of the teacher.
Diskretka, database, sites. Maybe a little more matan.
Economics, management. A little bit of coding.
Discrete, database and websites will be taught. Technology depends purely on the knowledge of the teacher.
Discrete, database and websites will be taught. Technology depends purely on the knowledge of the teacher.
I would advise "Software Engineering". In my opinion, in terms of programming, this specialty will give more than others.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question