Displaying post per day

This is quite basic but should help you on your way. //Get posts for the current week $args = array( ‘date_query’ => array( array( ‘year’ => date( ‘Y’ ), ‘week’ => date( ‘W’ ), ) ) ); //Check for search query if ( isset( $_GET[‘s’] ) ) { $args[‘s’] = $_GET[‘s’]; } //Create these variables … Read more

When to use wp_reset_postdata();

First we should talk about why you need to use wp_reset_query() in the first place. What wp_reset_query() does is reset the global $wp_query object back to it’s original state. Since you’re creating a new WP_Query object / instance, it does not overwrite the global $wp_query object. The only real case you would need to call … Read more

Why is it necessary to call rewind_posts() when using the loop more than once? [duplicate]

Global rewind_posts File: wp-includes/query.php 784: /** 785: * Rewind the loop posts. 786: * 787: * @since 1.5.0 788: * 789: * @global WP_Query $wp_query Global WP_Query instance. 790: */ 791: function rewind_posts() { 792: global $wp_query; 793: $wp_query->rewind_posts(); 794: } and rewind_posts from WP_Query class. File: wp-includes/class-wp-query.php 3144: * Rewind the posts and reset … Read more

Display subpages under parent page as a list within a loop

First set your arguments(settings) $args = array( ‘post_parent’ => get_the_ID(), ‘post_type’ => ‘page’, ‘numberposts’ => -1, ‘post_status’ => ‘publish’ ); $children = get_children( $args, $output ); then you can use something like this <?php if (!empty($children)):?> <ul class=”row”> <?php foreach($children as $dest){ $permalink = get_permalink($dest->ID); echo “<li class=”col-sm-4″><a href=”https://wordpress.stackexchange.com/questions/254608/{$permalink}”>” . $dest->post_title . “</li>”; }?> </ul> … Read more

Loop with Dynamic Categories

The code below enables categories for pages. An example page template is provided which loops through the categories assigned to the page and displays the posts for each category. If you want to limit the user to selecting only one category, you can use a solution such as Taxonomy Single Term. Associate the category taxonomy … Read more

WP_Query to loop a Custom Field, Custom Post Types do not show

There’s a missing opening quote and closing bracket on this line: <i class=<?php the_field(‘course_feature_icon’); ?>”</i> Needs to be: <i class=”<?php the_field(‘course_feature_icon’); ?>”></i> That’s all that’s wrong with your code. It should then work assuming: You have a custom field, course_feature_icon, whose value is a valid CSS class. You have the necessary CSS to add an … Read more

Group posts by custom field

You’re close. You have: foreach (get_child_pages(wp_get_post_parent_id(get_the_ID())) as $s) { echo ‘<li><a href=”‘ . get_the_permalink($s->ID) . ‘”>’ . get_the_title($s->ID) . ‘</a></li>’; } We need to add a layer above that to show the two lists. However we can’t assume that the posts of one type will all come out together (i.e. all of one category, then … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)