Skip Navigation

[Closed] Please help an idiot

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 11 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
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

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

This topic contains 4 replies, has 2 voices.

Last updated by michaelwalsh 11 years, 6 months ago.

Assisted by: Caridad.

Author
Posts
#19745

Hello,

So, to put it bluntly, my understanding of WP is mixed: i've built numerous sites, but my understanding of the core concepts is weak - likely because i do a lot of other things besides web development, and so it's rarely in the forefront of my mind for very long. Which is bad.

Anyway, as such, i have a question that will probably be laughably simple, but which i'd be very grateful if somone could answer for me:

I tend to call lists of posts using cos like this:

<?php
$articles = array(
'numberposts' => 3,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'articles',
'post_status' => 'publish'
);
$lastposts = get_posts( $articles );
foreach($lastposts as $articles) : ?>

...My understanding is that this is essentially outside of "the loop".

When I try to use, for example, something like this:
<?php echo (types_render_field("score", array("raw"=>"false", "output"=>"html"))); ?>

I get nothing at all returned. I believe that this is because i'm not in the Loop, and so, for want of better phrasing, WP doesn't know where to look.

I don't get any errors, just nothing at all.

.....A friend of mine is a competent programmer and so at some point he'll get my email asking for help, but on the off chance that takes a few days or what not, I'd really, really, really appreciate some help in understanding where I'm going wrong with this.

Thanks in advance - apologies for what is likely a fairly dumb question.

#19782

Dear Michael,

Try doing the loop like this:

<?php
$articles = array(
'numberposts' => 3,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'articles',
'post_status' => 'publish'
);
$my_query = new WP_Query($articles);
while ($my_query->have_posts()) {
$my_query->the_post();
<!-- Do stuff... -->
}
?>

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

Regards,
Caridad

#19834

Thanks CaridadZ, will try that a little later and let you know! Thanks very much for the suggestion, even if it turns out not to solve it!

#19989

Dear Michael,

When you try it, let me know if it works.

Thanks,
Caridad

#20144

Success! thank you - sorry for the slow reply -- including the new method alongside other code kept me rather busy!

Thanks again - brilliant! 🙂 That said, I'm sure I'll be back with other questions soon enough..

The topic ‘[Closed] Please help an idiot’ is closed to new replies.