First of all, you shouldn’t use get_posts
on your CPT archive – WP already creates a query and selects posts that should be display in there. So your archive-pjesma.php
should look like this:
<?php get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<h2><a href="https://wordpress.stackexchange.com/questions/326484/<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php // the_content(); ?>
<?php endwhile; ?>
<?php get_footer();
And you also should use simplified version of loop in your single-pjesma.php
:
<?php get_header(); ?>
<?php if ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endif; ?>
<?php get_footer();
Related Posts:
- Displaying recent post excerpts on static front page
- Suppress the_content filter in a nested loop
- Are content.php and content-single.php the same?
- Get ‘page’ number with infinite scroll
- Get 10 posts from a WP_Query. If less than 10, get the remainder from elsewhere
- Why doesn’t /2013/01/ properly return January’s archives in archive.php?
- Strategy to get post meta for use outside the loop
- Grab the first paragraph of each post
- Single Page WordPress Theme – Using page templates
- A two column loop with one lead post
- Responsive class to all the images in the content
- Change loop order via form or link (jquery, not URL)
- First post of each category
- Is there any need to use both wp_reset_postdata and wp_reset_query together?
- query posts in wordpress
- How to hide and content from auto-generated excerpts?
- Getting Permalink within the loop
- Why does this loop only work on the homepage?
- Setting hero/splash section as a blog post
- posts_nav_link(); not showing up on static pages
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- Finding Page Template and Displaying Content
- How WordPress converts URL to $query_string
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- Link won’t show using the_permalink();
- Some doubts about how to show posts in a custom theme?
- Force index.php have_posts() loop to exit if no sticky posts found
- show a post from a specific post format
- paged > max_num_pages won’t throw 404
- Limit Loop to 5 Posts?
- How to show user online status on their posts?
- Force Balance Tags not working
- Custom get_the_excerpt() only works on first post
- Echo all category names, apart from one
- How to place HTML tags in content from the_content()?
- Custom Blocks as part of a theme
- The Content is not Wraping in tag
- how to get the post attachement image in full size?
- Edit value of the_content() before showing
- Get the amount of posts on a given page
- How to list articles by year based on url?
- Change image size depending on page
- Why tags are displayed bellow the content and not inside
- How can I prevent posts with no title showing up in my query?
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- Post and page content not displaying in search results
- Previous and Next links not populating, have I missed something?
- Twenty Seventeen Pages Loop
- Single.php the_excerpt loads same as the_content not loading read more line
- pre_get_comments or the_content filter
- WordPress Load Only Page Text
- How does the loop know which post to view?
- Retrieve WordPress’ the_content() with jQuery
- Exclude subcategory from wp_query
- Style first 3 posts differently with WP_Query [duplicate]
- WP_Query not getting all posts, just tagged posts
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- Pagination and multiple loops
- Stop WordPress from showing images on non post pages
- How can I sort my loop based on meta data, using a form?
- List categories of a post hierarchically?
- Exclude parent categories from the_category() within the loop
- get_the_terms() returning wrong results inside of loop
- Show only pages you are author of
- Add class every 4 post like , class_1, class_2, class_3, class_4 and class_1, class_2, class_3, class_4
- How do I make my terms for each product display via foreach loop? (woocommerce)
- WordPress Insert ads after every 5th post
- White screen of death on index.php page 3 and above?
- Getting post URL within custom content template
- WordPress theme files Organization
- Infinite loop when nesting have_posts()
- Local variable name in setup_postdata()
- Loop is breaking my theme. How can I fix?
- my ajax wont sent the data, please correct my code
- control posts order by select option
- Problem with Displaying Custom Theme Page’s Content
- Why content is not adding for each blog post
- Strip HTML tags on custom code from the_content
- Best way to allow for extended use of WordPress functions inside single.php
- Conditional loop based on current page
- Loop through all posts, show attachment if there
- Tags interfering with next_post_link();
- Simple loop with shortcode rendering problem
- How get the 10 most viewed pages (not post)
- How to close open divs in post loop
- The normal loop with different styles doesn’t work in search.php
- Checking conditionals
- issue displaying variations in custom template using WPeC 3.8.9.2
- Confused on loading page content
- All post ids are the same after this query but rewind_posts() does not seem to work here?
- Not Found when using activity stream as front page with BuddyPress
- Why does the first loop take arguments from the second loop?
- have_posts() return false on single post
- How to defeat “Blog pages show at most __ posts” setting in the loop?
- Display Page featured Image as well as Posts featured Image
- WordPress Loop with Custom Post Type for Bootstrap Accordion [closed]
- Why am I getting posts back when I shouldnt
- Is there any reason that other theme elements (such as nav menus) shouldn’t be within the loop?
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- Return the_content() with custom div class for a subset of posts