Show number of posts AND number on current page (cannot make it work)
I actually had a duplicate of $page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
I actually had a duplicate of $page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
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
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
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’ => ” ) )
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
Try this: Paste it on functions.php (not tested) add_action(‘template_redirect’, ‘my_user_redirect’); function my_user_redirect(){ if(!is_user_logged_in()){ // only redirect use not logged in wp_redirect( home_url( ‘welcome’ ), 301 ); exit; } } Let me know if it worked.
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
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 }
The answer can be found in the documentation for get_the_title: $post (int|WP_Post) (Optional) Post ID or WP_Post object. Default is global $post. If you don’t supply a post object or post ID, it defaults to using the global $post variable. When you call the_post() within the loop, this populates the global $post variable with the … Read more
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