我有一个WordPress网络,有多个使用相同主题的网站。现在我需要编辑某个PageTemplate.php
根据blog id
.
示例:
如果日志ID为1,请运行以下操作:
<a href="<?php if(get_post_meta($post->ID, \'videoembed_videopopup\', true)): ?><?php echo get_post_meta($post->ID, \'videoembed_videopopup\', true) ?>
<?php else: ?>
<?php if(get_post_meta($post->ID, \'links_link_custom\', true)): ?><?php echo get_post_meta($post->ID, \'links_link_custom\', true) ?>
<?php else: ?>
<?php the_permalink(); ?>
<?php endif; ?><?php endif; ?>" class="hover-gradient <?php if(get_post_meta($post->ID, \'videoembed_videopopup\', true)): ?>video-pop-up<?php endif; ?>" target="_blank" <?php if(get_post_meta($post->ID, \'videoembed_videopopup\', true)): ?>rel="prettyPhoto[gallery]"<?php endif; ?>><?php the_post_thumbnail(\'progression-thumb-retina\'); ?></a><?php endif; ?>
否则,运行以下命令:
<?php if(get_post_meta($post->ID, \'links_link_custom\', true)): ?>
<a href="<?php echo get_post_meta($post->ID, \'links_link_custom\', true) ?>" class="hover-gradient <?php if(get_post_meta($post->ID, \'videoembed_videopopup\', true)): ?>video-pop-up<?php endif; ?>">
<?php else: ?>
<?php if(get_post_meta($post->ID, \'videoembed_videopopup\', true)): ?>
<a href="<?php echo get_post_meta($post->ID, \'videoembed_videopopup\', true) ?>" class="hover-gradient <?php if(get_post_meta($post->ID, \'videoembed_videopopup\', true)): ?>video-pop-up<?php endif; ?>">
<?php else: ?>
<?php endif; ?><?php endif; ?>
<?php the_post_thumbnail(\'progression-thumb-retina\'); ?></a>
<?php endif; ?>
我发现了这个条件,我相信这是实现我目标的途径:
<?php
global $blog_id;
if ($blog_id == 1) {
code here;
}
else {
code here;
}
?>
我如何将这两段代码放入blog id条件中,是否可能?如果没有,还有其他方法吗?