我正在改造现有网站的自适应布局.基本上在500px,该网站变为100%宽度的移动风格布局.通常我会使用ems,但正如我所说,我正在改装.
我知道如何有条件地加载js和css,但html和图像怎么样?
在网站的主页上有一个填满屏幕的大图像,在我的小屏幕布局上我不需要它,所以如果浏览器宽度超过500px,我希望它加载.麻烦的是我无法<img src="..." />在js中存储等等,因为它是动态加载的PHP.客户端通过wordpress admin控制图像.
任何想法将不胜感激.谢谢
我在法典中找到了这个:
// Filter to hide protected posts
function exclude_protected($where) {
global $wpdb;
return $where .= " AND {$wpdb->posts}.post_password = '' ";
}
// Decide where to display them
function exclude_protected_action($query) {
if( !is_single() && !is_page() && !is_admin() ) {
add_filter( 'posts_where', 'exclude_protected' );
}
}
// Action to queue the filter at the right time
add_action('pre_get_posts', 'exclude_protected_action');
Run Code Online (Sandbox Code Playgroud)
但这没有用。也许是因为我自定义了循环。我希望按照以下方式做一些简单的事情:
<?php $postsLatest = get_posts('numberposts=10&passwordproteced=false'); foreach($postsLatest as $post) { ?>
Run Code Online (Sandbox Code Playgroud)
那可能吗?