小编sha*_*ane的帖子

获取一系列子帖ID,wordpress 3.0,php

好的,这是一个...

在自定义模板上,我正在使用此代码来检索和显示子页面/帖子的列表

$args = array(
                    'depth'        => 1,
                    'show_date'    => '',
                    'date_format'  =>     get_option('date_format'),
                    'child_of'     => $post->ID,
                    'exclude'      => '',
                    'include'      => '',
                    'title_li'     => '',
                    'echo'         => 1,
                    'authors'      => '',
                    'sort_column'  => 'menu_order, post_title',
                    'link_before'  => '',
                    'link_after'   => '',
                    'walker' => '' );

                    wp_list_pages( $args );
Run Code Online (Sandbox Code Playgroud)

这很好用,我也想知道如何访问/创建array子帖ID.我的目标是custom fields通过get_post_meta()每个子帖的功能使用它的ID 访问一些元数据.

多谢你们.

php wordpress-theming

3
推荐指数
1
解决办法
5490
查看次数

php数组foreach循环

我的购物篮是一个array,其中的每个项目也是一个array.

在某些时候,我循环遍历每个项目寻找ID匹配.当我有匹配时,我需要知道主basket数组中的Items位置,以便我可以执行更新和删除.

听起来很简单,但我坚持下去.

到目前为止我有这个

//Lets say there are 5 items in this basket array (each item is also an array)
foreach ($_SESSION['basket'] as $basketArray){

        //this loops through the items attributes (size, colour etc)
        //when the ID is a match, i need to find out what position I am at in the main     array
        foreach($basketArray at $key = > $value){

             if ($value == $itemID){

                   //now I just need to know how to return 0, 1, …
Run Code Online (Sandbox Code Playgroud)

php foreach loops return

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

php ×2

foreach ×1

loops ×1

return ×1

wordpress-theming ×1