How i can display all posts order by years

You need to add an if statement current loop to print out a year container around your articles. <?php if( have_posts() ) : ?> <?php $current_year = date(‘Y’); // Get the current year and set it $first = true; // Set a $first variable; while ( have_posts() ) : the_post(); if ( $first || get_the_date(‘Y’) … Read more

How to looping taxonomy terms?

Rather than relying on a literal menu, you could use wp_list_pages possibly to better effect and sort out by certain criteria if you wish, then foreach page, display terms. Here is a little function I wrote to spit out terms for a taxonomy passed to it: // give taxonomy, will return link list to custom … Read more

Loop posts without any taxonomy

One solution would be to give a value of “none” to your posts without any post group, similarly as you have “uncategorized” posts in WP Categories. Alternatively… I haven’t checked it, but why don’t you try to make another WP_QUERY like this: new WP_Query( array( ‘post_type’ => ‘page’, ‘page_group’ => ” ) )

Divide loop into several columns based on post custom field and enable infinite scrolling

Use something like this for each column. <!– custom field = ‘normal’ –> <div class=”span2 normal”> <?php // The Query $the_query = new WP_Query( array( ‘meta_key’ => ‘your_custom_field_name’, ‘meta_value’ => ‘normal’ ); // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); echo ‘<div class=”post”> <h1>’ . get_the_title() . ‘</h1> </div>’; endwhile; // Reset Post Data … Read more

Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen

Run through the loop once and break when the sticky post is found. If it’s not found, rewind the query and output the first found result: <?php if ( $featured_value_cat_query->have_posts() ) { $count = 0; while ( $featured_value_cat_query->have_posts() ): $featured_value_cat_query->the_post(); if ( ‘yes’ == get_field(‘seacoast_value_sticky_value’) ) { $count = 1; ?> // Post Content would … Read more

Get categories by title descendant

If only you could use get_categories() reference in the Codex, you could see that this function supports arguments. <?php $categories = get_categories( array( ‘orderby’ => ‘name’, // default value, can omit it ‘order’ => ‘DESC’ )); foreach($categories as $cat) { // your code goes here }

Custom query for certain post type OR another post type with a certain category

First, take a look at this: https://developer.wordpress.org/reference/classes/wp_query/ You can filter by querying by post type, or in a single query (code between /* */). <?php //This is the first query $query_A = array( ‘post_type’ => ‘post_type_A’, ‘post_status’ => ‘publish’, //’cache_results’ => true, ‘posts_per_page’ => 10, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘fields’ => ‘ids’//add by … Read more

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