php – Order posts by hour with ACF and Timber (TWIG)

First of all I use ACF and Timber (TWIG).

I’m trying to create a calendar with a classification by year, month and hour.

I created a custom ACF field : event_date and an another field for start time event_hour_start

How I can order posts by hour for each month please ?


  • November
    • First event – 14:00
    • Second event – 16:00
  • December
    • First event – 11:00
    • Second event – 12:00


$events = Timber::get_posts(array(
    'post_type' => 'events',
    'meta_key'  => 'event_date',
    'orderby'   => 'meta_value_num',
    'order'     => 'DESC'

$events_list = array();

if($events) {
    foreach($events as $event) {
        $date = get_field('event_date', $event->ID, false);
        $hour_start = get_field('event_hour_start', $event->ID, false);
        $hour_end = get_field('event_hour_end', $event->ID, false);

        $date = new DateTime($date);

        $year = $date->format('Y');
        $month = $date->format('F');

        $events_list($year)($month)() = array($event, $date, $hour_start, $hour_end);

$context('events_list') = $events_list;


{% for year, years in events_list %}
    <p>Year : {{ year }}</p><br>
    {% for month, months in years %}
        <p>Month : {{ month }}</p>
        {% for event, events in months %}
            <p>{{ events(0).post_title }}</p><br>
        {% endfor %}
    {% endfor %}
{% endfor %}

Casino blog posts on quality blog




Link image:

Write & Publish TOP 5 Guest Posts DA80+ DoFoIIow Links for $30

Write & Publish TOP 5 Guest Posts DA80+ DoFoIIow Links

For the last 5 years, I’m working as a Digital Marketing seller and in this post, I’ll explain my TOP 5 dofollow Guest Posting service details.

I will write [well-researched, plagiarism-free, SEO-friendly] article and publish Guest Posts on high authority dofollow websites DA 80+ with permanent backlinks to your website to feature more program value.

This Guest Post may be a great opportunity for you. This Guest Post-service provides you the top quality, natural links that can surely assist you to spice up keyword ranking on search engines and obtain more traffic.

Website S.E.O Metrics: – DA 89 & DR 85 – DA 92 & DR 91 -DA 88 & DR 83 – DA 70 & DR 88 -DA 86 & DR 85
Link Type: DoFollow

What I will provide:
5 High Authority Dofollow Guest posts with DA80+
5 Unique 500 – 1000 words articles based on your website niche & keywords
Keyword Rich well-researched, plagiarism-free, SEO-friendly article.

You will receive an exact report with all the links where your blog posts are posted

Quick delivery.

100% satisfaction guaranteed.

Please Note:

  • I don’t accept all URLs except gambling, dating, adult, and pharmacy.
  • Permanent posts with DOFOLLOW backlinks.
  • I guarantee high-quality content.
  • No cheap article spinning or duplicate content.

If you have any questions about this service, please feel free to contact me.

Thank You!


Facebook albums not loading more than eighth posts. How to fix?

For some reason, Facebook (desktop UI) is not loading more than eighth posts in an album when “Feed view” is selected and the album page is scrolled down to the bottom. This problem exists for both my albums as well as that of friends. Problem is present on both Firefox and Chromium browsers with all addons/extensions disabled. The posts are mostly text-only posts, if it matters.

This problem did not exist in the classic / blue UI that Facebook had offered till August 2020.

How do I make Facebook load all the posts in an album?

wp query – Sort wordpress custom posts based on meta value

I’m trying to sort the custom posts based on meta value as priority level1, level2 and level3. I have given a dropdown field in post meta as featured posts, standard posts and basic posts. I want to display them as featured posts on top, then standard posts and then basic posts. I tried with below code but it’s not sorting the posts in the order.

Any guidance or advise much appreciated!

Here is my code:

    'name'          => __( 'Listing Type Options', 'text-domain' ),
    'id'            => 'lising_type_options',
    'type'          => 'select',
    'child_of' => '',
    'options' => array(
        '' => 'Select Listing Type',
        '1' => 'Basic',
        '2' => 'Standard',
        '3' => 'Featured',
    'desc' => ''

if( isset( $lp_type ) && !empty( $lp_type ) ){
     if( $lp_type == '3' ){
          $lp_type = 'Featured';
     } elseif( $lp_type == '2' ){
          $lp_type = 'Standard';
     } elseif( $lp_type == '1' ){
          $lp_type = 'Basic';
} else{
     $lp_type = '';

This is the query:

            $args = array(
                    'post_type' => $type,
                    'post_status' => 'publish',
                    'posts_per_page' => $postsonpage,
                    'paged'  => $paged,
                    'post__not_in' =>$ad_campaignsIDS,
                    'tax_query' => $TxQuery,
                    // 'meta_key'   => $MtKey,
                    // 'orderby' => $lporderby,
                    // 'order'   => $lporders,
                    'order'      => 'DESC',
                    'orderby'    => 'meta_value',
                    'meta_query' => array(
                        'relation' => 'OR',
                                    'relation' => 'OR',
                                        'key'     => 'lp_listingpro_options',
                                        'value'   => 'lising_type_options',
                                        'compare' => 'LIKE',
                                        'key'     => 'lp_listingpro_options',
                                        'value'   => 'lising_type_options',
                                        'compare' => 'NOT LIKE',

Ordering posts by custom field named “date” in backend

I defined a custom field named “date” and now want to order the post list in the backend by this field.

I defined the filters to make ordering work and header is clickable and shows the order arrow icon. The problem is that the post list gets ordered by publish date instead of custom field “date”.

function crimes_columns($columns) {
    $columns('crimedate') = 'Crime date';
    return $columns;
add_filter('manage_posts_columns', 'crimes_columns');

function crimes_show_columns($name) {
    global $post;
    switch ($name) {
        case 'crimedate':
            echo get_post_meta($post->ID, "date", true);
    return $row_output;
add_action('manage_posts_custom_column',  'crimes_show_columns');

add_filter( 'manage_edit-sortable_columns', 'crimes_add_custom_column_make_sortable' );
function crimes_add_custom_column_make_sortable( $columns ) {
    $columns('crimedate') = 'crimedate';
    return $columns;

add_action( 'pre_get_posts', 'crimes_orderby_meta' );
function crimes_orderby_meta( $query ) {
    $orderby = $query->get( 'orderby');
    if( 'crimedate' == $orderby ) {
        $query->set('meta_type', 'DATE');

Do you think the problem is the name of the field, do I have to rename the field to make it work? Or is there something wrong with my code?

customization – Include Sticky Posts with Custom Query

I’m working with Custom Query in WordPress, Basically, I’m showing 4 most recent posts of a category having ID 4
and my query is as follows:-

$args = array(
  'post_type' => 'post' ,
  'orderby' => 'date' ,
  'order' => 'DESC' ,
  'posts_per_page' => 4,
  'cat'         => '3',
  'paged' => get_query_var('paged'),
$q = new WP_Query($args);

This is working fine, but here I have an additional requirement. I want to add sticky posts as well i.e Posts will be stick to the top no matters these posts are recent or old, and total posts_per_page should be always 4 including sticky and recent posts.

e.g If there is no sticky post then I’ll show 4 most recent posts and no sticky post. But if there is 1 sticky post then there will be 1 sticky post and 3 most recent posts, a total of 4 posts.

What modification should I made in my Query? Thank you.

wp query – WP_Query to output chosen term and posts with no term assigned

I’m trying to build a query to filter a list of employees by a location taxonomy. Some staff are fixed, in that they’ll only ever work out of a single office, but others are flexible and work from them all.

If a user chooses to filter by Office 1, I want to display staff members assigned the Office 1 term for the location taxonomy and staff members with no term set at all.

For brevity I’ve stripped back the code below to the basic principles. I tried to set up a tax_query to query both the selected location and any posts without one set, but suspect the logic is flawed – any advice would be massively appreciated.

<!-- <select> field for user to select location -->
<form method="get">
    <select name="locations" id="locations">
    <option value="location-1">Location 1</option>
    <option value="location-2">Location 2</option>
    <option value="location-3">Location 3</option>
    <input type="submit">
// Target items by 'location' if option set in <select>
if(isset($_GET('locations'))) {
    $location = sanitize_text_field( $_GET('locations') );
    $tax_query() = array(
        'relation' => 'AND',
            'taxonomy' => location,
            'field'    => 'name',
            'terms'    => $location,
            'operator' => 'IN',
            'taxonomy' => location,
            'operator' => 'NOT IN',

// Configure query args
$args = array(
    'post_type'      => 'staff',
    'posts_per_page' => -1,
    'tax_query'      => $tax_query,
    'order'          => 'ASC',
    'post_status'    => 'publish'