A
A
Alexis_D2018-06-26 09:59:46
WordPress
Alexis_D, 2018-06-26 09:59:46

How to set up links to posts, wordpress?

I post entries with a link to it. When you click on the link, it redirects to the main one, if you specify "more" in the entry itself, the same story. What am I doing wrong? I want to click on the post link to go to it.
<a href="<?php the_permalink();?>">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sobolev, 2018-06-26
@san_jorich

Read about get_posts( $args ); setup_postdata($post); wp_reset_postdata();

global $post;
// !!! Аргументы настройте "под себя"
$args = array( 'numberposts' => 9 , 'category' => 1, 'orderby' => 'date');
$myposts = get_posts( $args );
foreach( $myposts as $post ){ setup_postdata($post);
?>
<div class="post">
<div class="post-img"><?php the_post_thumbnail('thumbnail'); ?></div>
<div class="post-txt">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<div class="post-date"><?php echo get_the_date('j F Y'); ?></div>
</div>
</div>
<?php
}
wp_reset_postdata();
// Код написан в качестве примера. Нужны правки и доработки

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question