Skip Navigation

[Resolved] Genesis – Featured Posts not showing on some pages of site

This support ticket is created 7 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 7 replies, has 2 voices.

Last updated by lindsayH 7 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#464963
Without Genesis Featured Posts.png
With Genesis - Featured Posts.png

On some pages where they are using a particular layout, the Genesis - Featured Posts is not there at all.

I've disabled all plugins and I can't see any javascript errors.

I added this to wp-config.php

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

Nothing displaying and can't see anything in the error_log.txt

In the Layout, there is a View and I removed [wpv-layout-meta-html] in the Filter and Loop Output Integration Editor section and it then works. But other than that I can't see what the issue is.

I have a staging site which I can give you login credentials for, in a private message - you can do anything in here re troubleshooting and I can send you a link to the offending Layout\View.

#465039

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Lindsay

You can go ahead and give me log-in credentials for your staging site.

You say that this happens "on some pages where they are using a particular layout".

Can you give me some specific urls of pages where it does and does not happen?

Marking your next reply as private.

#465374

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Lindsay

I'm puzzled by your set up.

You are using Layouts, and the working page you linked to uses a layout "Layout for events page" and the non-working page you linked to uses a layout "Listing page".

They are child layouts, but the parent layout ("Parent") doesn't contain anything apart from the child cell. No header, no footer. And they are not in the child layouts.

So I don't see where your footers are coming from to identify why one is behaving differently than another.

What am I missing?

#465516

I've used this in my custom functions for footers.

/* Reposition both fat footer and footer - Fluid Footer & Fluid EZ Fat Footer */
remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );
remove_action( 'genesis_footer', 'genesis_do_footer' );
remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 );
remove_action( 'wp_head', 'ez_fat_footer_structure' );

add_action( 'genesis_after', 'genesis_footer_markup_open' );
add_action( 'genesis_after', 'ez_fat_footer' );
add_action( 'genesis_after', 'genesis_footer_markup_close' );
add_action( 'genesis_after', 'sp_custom_footer' );
/* end Reposition both fat footer and footer */

But when I comment out the above code it doesn't resolve the problem.

Think this below in my custom functions is actually the issue. If I remove\comment out all is fine.

// Sort view by more than one sort order - listing.

add_filter('wpv_filter_query', 'add_custom_fields_to_listing_view_query', 99, 3);
function add_custom_fields_to_listing_view_query($query_args, $view_settings, $view_id ) {   

    if ($view_id == 270 ) {            
    $meta_query = array();
    $meta_query[] = array('key' => 'wpcf-featured-label');


        if ( !isset($query_args['meta_query']) ){
            $query_args['meta_query'] = array();
        }

    $query_args['meta_query'] = array_merge($meta_query, $query_args['meta_query']);
    add_filter('posts_orderby', 'custom_order_listing');

						}
	return $query_args;
	} 

function custom_order_listing($orderby) {
   global $wpdb;
   return $wpdb->postmeta.'.meta_value DESC, menu_order DESC, post_modified DESC';
}

Can you see anything obviously wrong with the above? I know this is outside your remit as custom code so I'll keep looking. Many thanks. Lins

#465780

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Lindsay

Is the purpose of that code just to add custom ordering for view id = 270?

You want to order by wpcf-featured-label then menu_order then post_modified, is that right?

I'm not sure why you are also using the posts_orderby filter.

If I have the above correct let me know and I can help you redraft the code.

#465891

Is the purpose of that code just to add custom ordering for view id = 270?
Yes.

You want to order by wpcf-featured-label then menu_order then post_modified, is that right?
Yes, spot on.

I'm not sure why you are also using the posts_orderby filter.
Me neither! Coding is not my forte, but it worked (before I realised then that there was the footer issue lol).

If I have the above correct let me know and I can help you redraft the code.
Thank you, thank you, thank you. Much appreciated.

#466524

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Lindsay

This one is fairly straightforward because you are using only one custom field (post meta) and two standard post fields.

And you can set up the first two in the view itself and then just append the third using the wpv_filter_query filter.

So in your view add the featured-label field as the first orderby option, then add menu_order as the secondary sorting option.

Now your code needs to look just like this:

/** 
 * Custom meta field sort order
 */
function custom_sort_order( $view_args, $view_settings, $view_id ){

	if ( $view_id == '270' ) {
		$view_args['orderby']['post_modified'] = 'DESC';
		error_log(print_r($view_args, true));
	}
	return $view_args;
}
add_filter( 'wpv_filter_query', 'custom_sort_order', 101, 3);

I left an error logging line in there so that you can see the generated query arguments.

#466583

Works a treat, thanks so much.

Think when I first created the code, there wasn't an option in the view to select a secondary sorting option... I wouldn't have got there without your help with the new code though.

Thank you again.

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.