Skip Navigation

[Resuelto] how to order types_child_posts()

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created hace 11 años, 2 meses. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 respuestas, has 3 mensajes.

Last updated by Jaime hace 10 años, 5 meses.

Assisted by: Luo Yang.

Autor
Mensajes
#34772

I'm trying to order the array returned by the types_child_posts() funtion by using orderby => meta_value_num, but I'm getting no results. Can this paramter be used for this function?

$args = array(
			'order' => 'ASC',
  			'orderby' => 'meta_value_num',
			'meta_key' => 'wpcf-performance-date'
		 );
		 
		$child_posts = types_child_posts('festival-performance',$args);
				foreach ($child_posts as $child_post) {
#34818

Hi Branigan,

This is because the types_child_posts() function is already using the meta_key for querying the parent.
You can try to query childs directly with get_posts and use the meta_query argument instead. Something like this should work:

$childargs = array(
'post_type' => 'festival-performance',
'numberposts' => -1,
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'wpcf-performance-date'
'meta_query' => array(array('key' => '_wpcf_belongs_producer_id', 'value' => get_the_ID()))
);
$child_posts = get_posts($childargs);

Please let me know if there is anything else that I can assist you with.

Regards
Luo

#34859

Thanks for your help - I'll give that a go. Would it also be possible to use these arguments/parameters in a wp_query() ?

#34972

Yes it is possible

#36892

Thanks for your assistance

#152377

Where i can put this code? In witch archive?

$childargs = array(
'post_type' => 'festival-performance',
'numberposts' => -1,
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'wpcf-performance-date'
'meta_query' => array(array('key' => '_wpcf_belongs_producer_id', 'value' => get_the_ID()))
);
$child_posts = get_posts($childargs);

In the same as:

$child_posts = types_child_posts('documentacion');
foreach ($child_posts as $child_post) {
echo $child_post->post_title;

El foro ‘Types Community Support’ está cerrado y no se permiten nuevos debates ni respuestas.

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