我知道我可以通过wp\\u insert\\u post将“post type”设置为“page”,以编程方式创建新页面
如何以编程方式编辑该页面?(标题、内容、段落等)
此外,如果我想以编程方式为该页面设置模板,我应该如何做?
我知道我可以通过wp\\u insert\\u post将“post type”设置为“page”,以编程方式创建新页面
如何以编程方式编辑该页面?(标题、内容、段落等)
此外,如果我想以编程方式为该页面设置模板,我应该如何做?
如果查看文档,可以使用wp_insert_post
然后使用update_post_meta
将模板分配给该帖子。
你可以这样写
$post_arr = array(
\'post_title\'=>\'My title goes here\',
\'post_content\'=>\'This is my long content.\',
\'post_excerpt\' => \'My Excerpt\',
\'post_status\' => \'publish\',
);
$new_post_id = wp_insert_post($post_arr);
然后像这样设置模板。update_post_meta( $new_post_id, \'_wp_page_template\', \'template-file.php\' );
查看更多选项的步骤wp_insert_post
, 您可以查看它的文档页面。在我的产品页面中,我添加了许多自定义分类法。其中之一就是被称为“colecciones”的分类学。例如,您可以在此URL中看到:https://www.editorialufv.es/catalogo/comunicacion-clinica/ 每本书都是一个集合的一部分(西班牙语为Coleccion)。我希望产品页面中出现的链接将重定向到我对每个收藏所做的页面,而不是商店页面过滤器。在这种情况下,Coleccion被称为“relación clínica”,他的URL是:https://www.edit