Support » Plugin: Toolset Types - Custom Post Types, Custom Fields and Taxonomies » How to display posts by current month?

  • Okay, so I created a custom field group titled for real estate properties as a test, and I’ve included essential information i.e. agent’s name, price of house, and a description of the property.

    I’ve created a custom archive PHP file to display posts for the current month, but it’s not quite working properly. Each post correctly displays the information with the right month of course, but the post doesn’t appear when I go to the monthly archives in the sidebar. I would also like to know if the current month parameter is working properly, but I don’t really know how and I was hoping if somebody could show me.

    Here is what I’ve done at the moment:

    /*Loops properties by month and archives them*/
    <?php get_header(); ?>
    <div class="container">
            // set current month to that of first post, and print it.
            $current_month = get_the_time('F Y');
            echo '<h2 class="archive">' . $current_month . '</h2>';
            //if ( is_post_type_archive('properties') ) {
            while (have_posts()) : the_post('properties');
            echo '<div class="property">';
                    echo "<span>";
                        echo the_title();
                        echo "</span>";
                        echo "<span id=\"agent\">";
                        echo(types_render_field("property-agent", array( 'raw'=> true)));
                        echo ",</span>";
                        echo "<p>";
                        echo(types_render_field("property-sale", array( 'raw'=> true)));
                        echo "</p>";
                echo "<div class=\"description\">";
                     echo( types_render_field("description", array( 'raw'=> true)));
                echo "</div>"/*end description*/;
                echo '<a class="spotlight-link" href="'.get_permalink().'">Read More</a>';
            echo "</div>";    
                // check each subsequent post to see if the month is the same
                // or has changed and needs to be printed:
                $this_month = get_the_time('F Y');
                if( $this_month!=$current_month ):
                    $current_month = $this_month;
                    echo '<h2 class="month-title">' . $current_month . '</h2>';
        //  }
            <?php if (  $wp_query->max_num_pages > 1 ) {
    <?php get_footer(); ?>


Viewing 1 replies (of 1 total)
  • Plugin Support Beda


    You can see here how to create Custom WordPress Archive Templates.

    We don’t provide Custom Code assistance.

    To render Types Fields in any PHP template you can refer to this API DOC.

    Thank you

Viewing 1 replies (of 1 total)
  • The topic ‘How to display posts by current month?’ is closed to new replies.