Skip Navigation

[Resolved] 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 9 years, 6 months ago. 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
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 24 replies, has 2 voices.

Last updated by Adriano 9 years, 5 months ago.

Assisted by: Adriano.

Author
Posts
#253885

Hi,

I use the function types_child_posts() in many template in my theme. However I cannot get the same result when I use it in the category template.

I tried in many ways to make it work in a category template and I have no results. Everything works as if there was no child posts for my custom post type.

Any Idea why and how I could fix this?

Thanks !

#253986

I'm not sure if it will works well in taxonomies templates. Please explain me in details what you want to achieve and I will give you an alternative solution.

#253988

Hi, thanks for the reply. I have a custom query in my category template which is the following :

<table class="tablepart">
  <tbody>
  <tr>
    <th>Marchand</th>
    <th>Cashback</th>
    <th>Code promo & offres</th>
  </tr>

 
<?php 

$my_query_args = array(
    'posts_per_page' => -1,
    'post_type' => 'partenaire',
    'order' => 'ASC',
    'orderby' => 'title',
    'tax_query' => array(
        array(
            'taxonomy' => 'category',
            'field' => 'id',
            'terms' => $category_id 
        )
    )
);

$my_query = new WP_Query( $my_query_args ); 
if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post();

$child_posts = type_child_posts('coupon');
$child_post = count($child_posts);

?>
 <tr data-href="<?php  the_permalink();  ?>">
<td><?php if($child_post>=1) {echo '<i class="icon-tag"></i>'; }?></td>
</tr>

<?php endwhile; endif;  ?>
</tbody>
</table>
<div class="clear"></div>

It's not the exact code but the essence of it. I have the exact same piece of code in other templates and it works fine. In category template something is amiss...I don't know what... 🙁

#254270

I've tried the same code on my localhost and it works fine. The types_child_posts() works in any WordPress template file you want to use, because it uses the current post ID to show the child posts.

Do you have sure that the slug of the parent is "partenaire" and the child is "coupon"?

Try to put this code below to test it better:

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

Please let me know if you are satisfied with my answer and if I can help you with any other related question.

#254296

Hi,

I'm 100% sure that coupon is a child of father...Anyway it works fine in others templates.

$child_posts is an array so I tried to print the array and it's always empty. It works in my search template or in a custom page template but not in the category template.

I use the last version of wp-types but I don't have 4.0 wordpress...I really don't know why the get_posts function (types_child_posts() use get_posts right?) doesn't work here. Because I tried to use get_posts in my custom loop and it doesn't work.

#254571

I need to request temporary access (wp-admin and FTP) to your site - preferably to a test site where the problem has been replicated if possible - in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

#257668

Hi,

I don't have the permission to send such access. You could tell me what's in your mind, where do you think the problem would come from?

To be more accurate here the problem is located in the category.php template. The slug isn't category but /miles/ .

There is no posts in the category but only custom post which I created with types.

#259677

I must be honest with you, I don't have nothing special in mind. I would just check everything because that's working fine on my local tests.

In case you can't provide one we could prepare a test site for you. So you can reproduce the same issue there and we can play in a common place. Would you like?

#259702

Hi,

That would be nice indeed. Let me know where I can reproduce the same issue and I will try to do it.

Thanks

#259938

The test site has been set up for you. You should receive an email explaining all procedures. Please let me know as soon as you are done.

#260360

Hi, Sorry but I didn't get any mail from you or Toolset...Could you try to send it again please?

#260368

Sorry about that. Sure, I will do this. The problem is that the person responsible for this is offline. You should receive this tomorrow. Thank you for your understanding.

#260369

Anyway I would ask you to check your spam / trash folder.

#260374

Please check your email, I've just sent instructions by there.

#261276

Hi,

Thanks for your time for this.

I tried to set up the same problem and at the beggining I couldn't, it worked fine. But as soon as I change the functions.php for mine own one, I could reproduced the issue: hidden link

So I use the types child posts function in the category template. If it works it shows: "5okok" in the third cell in the table. It doesn't at the moment.

The forum ‘Types Community Support’ is closed to new topics and replies.

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