我正在努力解决这个问题,我唯一能想到的方法是通过WP\\U查询引入内容,但查询中不能包含查询,不是吗?
我想做的是:
主顶层页面,子页面,子页面,所以我要实现的是有一个页面,列出所有子页面(子页面),然后还显示第一个子页面的所有子页面。本质上类似于所述类别中的类别和项目列表。
我所需要的只是子页面的链接和名称,然后是子页面的链接、名称和特色图片。
有人能帮我从哪里开始吗?
我正在努力解决这个问题,我唯一能想到的方法是通过WP\\U查询引入内容,但查询中不能包含查询,不是吗?
我想做的是:
主顶层页面,子页面,子页面,所以我要实现的是有一个页面,列出所有子页面(子页面),然后还显示第一个子页面的所有子页面。本质上类似于所述类别中的类别和项目列表。
我所需要的只是子页面的链接和名称,然后是子页面的链接、名称和特色图片。
有人能帮我从哪里开始吗?
将get_pages()
为你工作?http://codex.wordpress.org/Function_Reference/get_pages
如果我正确理解了你的问题,你会想要这样的东西:
$children_of_page = get_pages(array(
\'child_of\' => $post->ID,
\'parent\' => $post->ID //defining both parent and child forces the list to only include direct children.
));
$children_of_first_child = get_pages(array(
\'child_of\' => $children_of_page[0][ID],
\'parent\' => $children_of_page[0][ID]
));
如果要直接输出列表,可以使用wp_list_pages()
, http://codex.wordpress.org/Template_Tags/wp_list_pages, 类似于:wp_list_pages(array( //Get first level children of current page and output as list
\'child_of\' => $post->ID,
\'depth\' => 1,
\'title_li\' => \'\'
));
$children = get_pages(array(
\'child_of\' => $post->ID,
\'parent\' => $post->ID
));
wp_list_pages(array( //output the children of the first child
\'child_of\' => $children[0][ID],
\'depth\' => 1,
\'title_li\' => \'\'
));
根据需要打乱论据,以得到你想要的东西。我需要在wordpress中执行我的个人php代码来打印mysql数据库中的数据。我只能在页面上执行。我的想法是创建一个文件页pagename。php,复制页面主体。php模板并更改此代码:<?php while ( have_posts() ): the_post(); ?> <article <?php post_class(\'group\'); ?>> <?php get_temp