Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 539557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:08:54+00:00 2026-05-13T10:08:54+00:00

I am attempting to display a list of users based on a month value.

  • 0

I am attempting to display a list of users based on a month value. I want to display January then all the users associated with it etc…

What i have now is working correctly for the first months then does nothing after. I have comments in the code and a live version of this code is running at: http://blog.funeraldirectorslife.com/participants/

<?php
/*
Template Name: Participants
*/
?>
<?php
    function display_user($author, $month){
        $ID = $author->ID;
        $full_name = get_the_author_meta('display_name', $ID);
        $usr_name = get_the_author_meta('user_nicename', $ID);
        $sab_descriptiom = get_cimyFieldValue("$ID", 'Sabbatical_desc');
        $sab_start = get_cimyFieldValue("$ID", 'Sabbatical_Start');
        $sab_end = get_cimyFieldValue("$ID", 'Sabbatical_End');
        $sab_month = get_cimyFieldValue("$ID", 'Sabbatical_Month');
        $author_posts = $author->num_posts;
        //$months = array(January, February, March, April, May, June, July, August, September, October, November, December);
        //echo $sab_month;

        if ($sab_month == $month){
            echo "<li>";                                    
            echo "<h4 class=\"nomar\"><a href=\"http://blog.funeraldirectorslife.com/author/" 
                    . $usr_name                                  
                    ."\">"
                    .$full_name 
                    ."(" 
                    . $author_posts
                    . ")" 
                    . "</a>" 
                    . "</h4>";
            echo    $sab_start 
                    . " - " 
                    . $sab_end 
                    . "<br />";
            echo    $sab_descriptiom 
                    . "<br />"
                    . $sab_month . "</br>" . "</li>" . "\n";
        }
        else {
            return;
        }
    }

?>
<?php get_header(); ?>
<div id="bd" class="grid_12 alpha omega clearfix">
    <?php get_sidebar(); ?>
    <div id="main" class="grid_9 omega">
        <?php include(TEMPLATEPATH . '/banner.php'); ?>

        <div class="unit">
            <!--
            <div class="head">
                <div class="title"><h3><span>Blog Entries</span></h3></div>
            </div>
            //-->
            <div class="body clearfix">
                <ul class="styled_list">

                    <li class ="alpha"><h3 class="nomar"><a href="<?php the_permalink(); ?>"><span><?php the_title(); ?></span></a></h3></li>


                    <?php                       
                    //grab authors ids, post count, and extended info from database
                    //fill $authors array with data
                    $sql = "SELECT * FROM `wp_users` WHERE 1 ORDER BY ID";  
                    $results = $wpdb->get_results($sql);
                    $authors = $results;

                    $author_count = array();
                    $rows = $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author");
                    foreach ($rows as $row) {
                        $author_count[$row->post_author] = $row->count;
                    }
                    //combine queries
                    foreach( $authors as $author ) {
                        $author->num_posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0;
                    }

                    //month array for comparing with sabbatical month 
                    $months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October','November', 'December');


                    //tried old method for iterating arrays --> same result
                    /*reset($months);
                    while (list($key, $month) = each($months)){
                        echo "<h2 class=\"nomar\">" .  $month . "</h2>" . "\n";

                        foreach($authors as $author) {
                            display_user($author, $month);  
                            //echo $author->ID;
                        }
                    }*/



                    foreach($months as $month ) {
                        echo "<h2 class=\"nomar\">" .  $month . "</h2>" . "\n";

                        foreach($authors as $author) {
                            display_user($author, $month);  
                            //echo $author->ID;
                        }


                        //lists authors by ID - just making sure array is intact after each author loop
                        /*foreach($authors as $author) {
                            $ID = $author->ID;
                            $foo = get_cimyFieldValue("$ID", 'Sabbatical_Month');
                            echo $ID . $foo . "<br /> . "\n"";                  
                        }*/
                    }
                    ?>
                </ul>
            </div>      
        </div>
    </div>
</div>
<?php get_footer(); 

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:08:54+00:00Added an answer on May 13, 2026 at 10:08 am

    I’m not sure if it will work properly, but I have updated your code somewhat. Mainly I added the trim() function when comparing your $sab_month and $month but I also cleaned up your code a bit. You can embed variables inside of a double-quoted string in PHP, so you don’t have to concatenate them 🙂

    <?php /* Template Name: Participants */ ?>
    
    <?php
        function display_user($author, $month){
            $ID = $author->ID;
            $full_name = get_the_author_meta('display_name', $ID);
            $usr_name = get_the_author_meta('user_nicename', $ID);
            $sab_descriptiom = get_cimyFieldValue("$ID", 'Sabbatical_desc');
            $sab_start = get_cimyFieldValue("$ID", 'Sabbatical_Start');
            $sab_end = get_cimyFieldValue("$ID", 'Sabbatical_End');
            $sab_month = get_cimyFieldValue("$ID", 'Sabbatical_Month');
            $author_posts = $author->num_posts;
            //$months = array(January, February, March, April, May, June, July, August, September, October, November, December);
            //echo $sab_month;
    
            if (trim($sab_month) == trim($month)){
                echo "<li>";                                    
                echo "  <h4 class='nomar'><a href='http://blog.funeraldirectorslife.com/author/$usr_name'>$full_name($author_posts)</a></h4>";
                echo "  $sab_start - $sab_end<br />";
                echo "  $sab_descriptiom<br />";
                echo "  $sab_month</br>";
                    echo "</li>\n";
            }
                /* Not necessary. The function will return when it hits the end
            else {
                return;
            }
                */
        }
    
    ?>
    <?php get_header(); ?>
    <div id="bd" class="grid_12 alpha omega clearfix">
        <?php get_sidebar(); ?>
        <div id="main" class="grid_9 omega">
            <?php include(TEMPLATEPATH . '/banner.php'); ?>
    
            <div class="unit">
                <!--
                <div class="head">
                    <div class="title"><h3><span>Blog Entries</span></h3></div>
                </div>
                //-->
                <div class="body clearfix">
                    <ul class="styled_list">
    
                        <li class ="alpha"><h3 class="nomar"><a href="<?php the_permalink(); ?>"><span><?php the_title(); ?></span></a></h3></li>
    
    
                        <?php                       
                        //grab authors ids, post count, and extended info from database
                        //fill $authors array with data
                        $sql = "SELECT * FROM `wp_users` WHERE 1 ORDER BY ID";  
                        $results = $wpdb->get_results($sql);
                        $authors = $results;
    
                        $author_count = array();
                        $rows = $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author");
                        foreach ($rows as $row) {
                            $author_count[$row->post_author] = $row->count;
                        }
                        //combine queries
                        foreach( $authors as $author ) {
                            $author->num_posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0;
                        }
    
                        //month array for comparing with sabbatical month 
                        $months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October','November', 'December');
    
    
                        //tried old method for iterating arrays --> same result
                        /*reset($months);
                        while (list($key, $month) = each($months)){
                            echo "<h2 class=\"nomar\">" .  $month . "</h2>" . "\n";
    
                            foreach($authors as $author) {
                                display_user($author, $month);  
                                //echo $author->ID;
                            }
                        }*/
    
    
    
                        foreach($months as $month) {
                            echo "<h2 class='nomar'>$month</h2>\n";
    
                            foreach($authors as $author) {
                                display_user($author, $month);  
                                //echo $author->ID;
                            }
    
                            //lists authors by ID - just making sure array is intact after each author loop
                            /*foreach($authors as $author) {
                                $ID = $author->ID;
                                $foo = get_cimyFieldValue("$ID", 'Sabbatical_Month');
                                echo $ID . $foo . "<br /> . "\n"";                  
                            }*/
                        }
                        ?>
                    </ul>
                </div>      
            </div>
        </div>
    </div>
    <?php get_footer(); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to display a LargeIcon view in a listview control, however the images
I'm attempting to display some text in my program using (say) Windows GDI and
I'm attempting to display some text in my program using (say) Windows GDI and
Attempting to print out a list of values from 2 different variables that are
Attempting to insert an escape character into a table results in a warning. For
Attempting to deploy a MOSS solution to a UAT server from dev server for
When attempting to compile my C# project, I get the following error: 'C:\Documents and
When attempting to call functions in math.h , I'm getting link errors like the
When attempting to understand how a SQL statement is executing, it is sometimes recommended
Does attempting to develop some sort of game, even just as a hobby during

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.