custom query – offset to pagination
custom query – offset to pagination
custom query – offset to pagination
Modify category archive page loop on functions.php
If it’s your main loop, you could add this to your function.php: function custom_pre_get_posts($query) { if($query->is_main_query() && /* is sticky conditional tag(sorry I need to check what is that) */) { $query->set(‘posts_per_page’, “1”); } } add_action(‘pre_get_posts’, ‘custom_pre_get_posts’); Or you can make a new WP_Query instance in the theme file: <?php $onePost = new WP_Query(array( ‘post_type’ … Read more
To display ‘news’, you’ll have to add it to your loop arguments: $wp_query->query( ‘post_type’ => ‘news’, ‘posts_per_page=”.get_option(“posts_per_page’).’&paged=’.$paged );
@Milo’s answer worked perfectly (see comment above). if (in_array($post->ID, $do_not_duplicate)) continue; meant that duplicate posts were still being counted in the loop, though not being displayed. To fix, remove this line, and exclude duplicate posts from the query with this argument: ‘post__not_in’ => $do_not_duplicate. Thank you @Milo for your swift and succinct response.
Maybe you can try with get_posts() and foreach loop for the second query instead of WP_Query and then you will have something like this: <?php $secondary_query = get_posts(‘category_name=students’); foreach($secondary_query as $secondary_post): echo “<li>” . get_the_title($secondary_post->ID) . “</li>”; endforeach; ?> With above like style you don’t need wp_reset_query() just make sure you pass the post ID … Read more
get_queried_object_ID() will return the ID on the page for posts, or get_queried_object() will return the page object containing all its post fields. Alternately, the ID of the blog page is stored in the option page_for_posts, which is internally how get_queried_object gets the ID of the post object to load.
What about add else { after get_template_part( ‘template-parts/content’, ‘video’); }? EDIT (1) : <?php /** * The template for displaying single posts. * * @package SN */ get_header(); ?> <?php while ( have_posts() ) : the_post(); ?> <?php if( has_post_format(‘video’)) { get_template_part( ‘template-parts/content’, ‘video’); }else{ ?> <div id=”content-wrapper”> <div id=”primary” class=”content-area”> <main id=”main” class=”site-main” role=”main”> … Read more
You have just created the template. You still need to create the entire function of the form. It would be easier to just copy a comment.php and then edit it out with some CSS to get it to look like what you want it to. The link below is for a default comment.php that should … Read more
You can use the add_meta_boxes hook to place a text field in the desired pages. Then on the template page you can check whether the user has entered some categories (display all categories if not) and filter the loop using the WP_Query, query_posts() or get_posts(). Here is an excellent article on the three methods.