我想设置一个不包含在内容中的库,以便能够在主题文件中访问它。
目前,我使用的虚拟页面只包含库,无法从前端访问。我宁愿跳过这一步,并将库设置保留在显示它的页面上。
如果必须将库包含在内容中,我能否以模板特定的方式修改对短代码的处理,并在调用之前包含库the_content();
?
我想设置一个不包含在内容中的库,以便能够在主题文件中访问它。
目前,我使用的虚拟页面只包含库,无法从前端访问。我宁愿跳过这一步,并将库设置保留在显示它的页面上。
如果必须将库包含在内容中,我能否以模板特定的方式修改对短代码的处理,并在调用之前包含库the_content();
?
我已经用它在我的一些网站的内容下显示了图库,或者在自定义位置,你可以根据需要对其进行操作。唯一的回退(某种程度上)是,如果有2个库,它将只适用于第一个库。
<?php
get_header();
// Get Post Gallery before The Loop
global $post;
$gallery = get_post_gallery($post->ID);
?>
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
$content = strip_shortcode_gallery( get_the_content() ); // remove Gallery Shortcode
$content = str_replace( \']]>\', \']]>\', apply_filters( \'the_content\', $content ) ); // Resetup Content
echo $content; // Echo Content
<?php endwhile; ?>
<?php endif; ?>
<div id="gallery">
<?php echo $gallery; ?>
</div>
<?php get_footer(); ?>
Functions.php
function strip_shortcode_gallery( $content ) {
preg_match_all( \'/\'. get_shortcode_regex() .\'/s\', $content, $matches, PREG_SET_ORDER );
if ( ! empty( $matches ) ) {
foreach ( $matches as $shortcode ) {
if ( \'gallery\' === $shortcode[2] ) {
$pos = strpos( $content, $shortcode[0] );
if ($pos !== false)
return substr_replace( $content, \'\', $pos, strlen($shortcode[0]) );
}
}
}
return $content;
}
你能告诉我怎么找到厨房的身份证吗?我们可以在CSS样式中使用这个ID吗?如果没有,我们如何以不同的风格设计两个不同的画廊?(老实说,我不确定这是否可能,但我希望!)