【问题标题】:Make CPT archive editable and integrate Thrive Architect使 CPT 存档可编辑并集成 Thrive Architect
【发布时间】:2019-04-17 02:32:11
【问题描述】:

刚刚碰到这个关于 CPT 存档页面的问题,有没有办法让它像一个页面/帖子一样,你可以在上面编辑和添加内容?

目前我的方法是做一个普通的页面,然后用壮大架构师布局页面,然后保存

然后在 CPT 存档页面上,我只需添加一个查询来提取我刚刚创建的那个页面的内容

$the_query = new WP_Query( 'page_id=9755' );
while ( $the_query->have_posts() ) :
$the_query->the_post();
the_content();
endwhile;
wp_reset_postdata();

现在内容显示在我的 CPT 存档中,现在的问题是样式不同,我认为这与 CTP 存档中不存在的兴旺建筑师 ID 使用有关

这意味着我的内容正常,但布局不正常

<style class="tve_custom_style"></style> 

两者都不同,所以我如何将该页面上的样式表获取到我的 CPT 存档页面

【问题讨论】:

  • 您目前做得正确。标记有什么区别?似乎您可以使用 CSS 轻松解决此问题,或者将 query 包装在同一标记中。
  • 好吧,在普通页面上,我将容器宽度设置为 1000px,但在 CPT 存档中它的全宽,这种类型的 css [data-css="tve-u-169d7a7171b"] 也是在 CPT 存档中不可见

标签: php css wordpress custom-post-type


【解决方案1】:

我刚刚解决了我自己的问题,这是我的解决方案

因为我在 CPT 存档中这样做

$the_query = new WP_Query( 'page_id=9755' );
while ( $the_query->have_posts() ) :
$the_query->the_post();
the_content();
endwhile;
wp_reset_postdata();

css 布局不遵循从原始页面到我的 CPT 存档

解决办法是

<?php 
$custom_css = trim( tve_get_post_meta( 9755, 'tve_custom_css', true ) . tve_get_post_meta( 9755, 'tve_user_custom_css', true ) );
echo '<style>';
echo $custom_css;
echo '</style>';
?>

以便 tve_get_post_meta() 将样式表从该页面拉到我的 CPT 存档中

一切正常...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多