WordPress Custom Theme: My site shows the same posts on Page 1 and Page 2 and so on [duplicate]

You need to pass posts_per_page and paged param. $args = array( ‘post_type’ => ‘nutrisense_nieuws’, ‘posts_per_page’ => get_option(‘posts_per_page’); // number of posts to show per page ‘paged’ => get_query_var( ‘paged’, 1 ) // get page if set else page 1, Use “page” for static front page instead of “paged” see the links. ); $the_query = new … Read more

Automatically add class to link based on link text

If I understand it correctly you want a visual indicator for departures relevant on the current time. One solution will be using Javascript and provide a way for the element to be identified as passed or active schedule time. HTML <div id=”myElement”> <a href=”https://myawesomenewsite.com/departuretime/1253″>1253</a> <a href=”https://myawesomenewsite.com/departuretime/1255″>1255</a> <a href=”https://myawesomenewsite.com/departuretime/0955″>0955</a> <a href=”https://myawesomenewsite.com/departuretime/2213″>2213</a> </div> JAVASCRIPT // find elements … Read more

WordPress posts [closed]

There are multiple ways to accomplish this, depending on your expertise and specific needs. First of all, you have not specified how these four posts are selected. Do you want to select them manually in the backend? Or are they the 4 most recent posts? Or random? Or from a specific category? Depending on the … Read more

Query posts by custom fields (object post)

If you use Post Object field type, then it is stored as ID in custom field. So this should do the trick: $posts = get_posts(array( ‘numberposts’ => -1, ‘post_type’ => ‘post’, ‘meta_key’ => ‘<FIELD_NAME>’, ‘meta_value’ => <POST_ID> )); PS. You should use ‘posts_per_page’ instead of ‘numberposts’ (which is deprecated).

custom post type single page template not working

Please see the Template Hierarchy. There is no template-portfolio.php template. It needs to be archive-portfolio.php. Also, you should not be using a custom query*. Use the main query in your post type archive templates. WordPress already queries the correct posts for you. So remove: $portfolio = new WP_Query(‘post_type’=> ‘portfolio’); And replace: while ($portfolio-> have_posts() ) … Read more

First post in loop displays twice

The else of the $change % 5 == 0 also runs when $change is a 1 and that is why the first post is displayed twice. You could fix it by changing <?php $change++ ?> <?php endif; ?> <?php if ( $change % 5 == 0 ) : ?> to <?php $change++ ?> <?php elseif … Read more

Next and Previous Pagination button not displaying in WordPress

You’re using a custom query (new WP_Query), so you need to pass $tyler_query->max_num_pages (the max pages) to the next_posts_link() function — more details here: next_posts_link( null, $tyler_query->max_num_pages ) And btw, no need to echo with previous_posts_link() because the function indeed echoes the output. I.e. Just do so: <?php previous_posts_link(); ?>. Also, you should add paged … Read more

How can we pass a value from the_permalink() at WordPress?

the_permalink() only displays the URL for the current post in the loop. If you want to link to another post, you can use echo get_the_permalink( 123 );, where 123 is a post ID. <a href=”https://wordpress.stackexchange.com/questions/353261/<?php echo get_the_permalink( 123 ) ?>”> Note that the_permalink() and get_the_permalink() only get URLs for posts. If you want to get … Read more