我想通过 ID 获取自定义帖子类型的内容,并在短代码中返回它。我找到了多种方法来做到这一点。但是他们<p>都从内容中删除了-tags。这是我尝试过的:// Get the ID from a meta field$post_id = $id;// Method 1$banner_content = get_post($post_id);$content = $banner_content->post_content;// Method 2$content = apply_filters('the_content', get_post_field('post_content', $post_id));// Method 3$content_post = get_post($post_id);$content = $content_post->post_content;$content = apply_filters('the_content', $content);$content = str_replace(']]>', ']]>', $content);// Method 4$content = get_post_field('post_content', $post_id);// Output in a shortcodereturn '<div>'.$content.'</div>';有没有办法保留<p>-tag?
- 1 回答
- 0 关注
- 123 浏览
添加回答
举报
0/150
提交
取消