所以我有这个功能代码,将"类别"添加到我在Wordpress网站上传的图像中.
/** Register taxonomy for images */
function olab_register_taxonomy_for_images() {
register_taxonomy_for_object_type( 'category', 'attachment' );
}
add_action( 'init', 'olab_register_taxonomy_for_images' );
/** Add a category filter to images */
function olab_add_image_category_filter() {
$screen = get_current_screen();
if ( 'upload' == $screen->id ) {
$dropdown_options = array( 'show_option_all' => __( 'View all categories', 'olab' ), 'hide_empty' => false, 'hierarchical' => true, 'orderby' => 'name', );
wp_dropdown_categories( $dropdown_options );
}
}
add_action( 'restrict_manage_posts', 'olab_add_image_category_filter' );
Run Code Online (Sandbox Code Playgroud)

我想知道如何调用或显示属于特定类别的所有图像(我要调用的类别编号是#2190类别)?
我在这里要做的是建立一个照片库,展示我上传的所有照片,并标记为#2190类别 - "当天的照片"?
我想要完成的是代码将自动检测<?php the_author_ID(); ?>博客帖子的作者ID .一旦它具有作者ID,它将执行一项简单的任务.如果作者#等于2,则调用函数sBadong.否则,如果作者ID等于3,则调用函数sJade.如果不满足两个条件,则调用函数sBen.
这是我的代码,但它不起作用.我不知道它有什么不妥.你能帮我吗?
<?php
$author_id=$post->post_author;
if ($author_id == "2") {
echo sBadong();
} elseif ($author_id == "3") {
echo sJade();
} else {
echo sBen();
}
?>
Run Code Online (Sandbox Code Playgroud)
上面代码的问题是它没有读取帖子的作者编号.它总是返回函数sBen(); 并忽略所有if和else语句.
你知道如何编写PHP脚本或Javascript来检测用户的屏幕大小然后执行IF而不测试然后结果会返回特定的显示吗?
我想在这里完成的事情:
Javascript将检测我的网站的用户/访问者的分辨率.(我使用媒体查询得到了这个,我在这方面没有问题)
然后脚本将执行IF和ELSE功能.如果用户的分辨率= <320x480(移动电话的分辨率),PHP脚本将调用Google Adsense - 移动电话的代码.如果没有,那么它将显示Google Adsense网站的代码.
2个google adsense代码保存在两个不同的文件中,我们只需将它们称为adsense-Mobile.php和adsense-Website.php
这是一个简单的流程图.

这就是我遇到的问题.许多专家说,Jquery中的一个简单的SHOW-HIDE元素可以完成这项工作.不幸的是,在我的情况下,它没有.
我已经这样做了,它不符合我的要求.问题是来自谷歌的两个广告一次性加载到网站中,只有1个被显示.Google Adsense仅允许展示3个广告.如果我做show-hide jquery,我将失去创造收入的机会,因为其中一个广告是隐藏的.我需要一些不会加载两个代码的东西但只能调用正确的代码(正确的大小,无论是移动还是网站).
我知道PHP可以做到这一点,但我不知道从哪里开始或者我应该开始阅读或研究什么功能.非常需要你的帮助.有任何想法吗?任何PHP或javascript只能调用一个谷歌adsense代码取决于分辨率.
这是谷歌adsense移动和网站的代码.
Google Adsense代码 - 网站
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6099979626157131";
/* Ben Daggers Leader Board */
google_ad_slot = "8829449662";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Run Code Online (Sandbox Code Playgroud)
Google Adsense代码 - MOBILE
<?php
$GLOBALS['google']['client']='ca-mb-pub-6099979626157131';
$GLOBALS['google']['https']=read_global('HTTPS');
$GLOBALS['google']['ip']=read_global('REMOTE_ADDR');
$GLOBALS['google']['markup']='xhtml';
$GLOBALS['google']['output']='xhtml';
$GLOBALS['google']['ref']=read_global('HTTP_REFERER');
$GLOBALS['google']['slotname']='8668582435';
$GLOBALS['google']['url']=read_global('HTTP_HOST') . read_global('REQUEST_URI');
$GLOBALS['google']['useragent']=read_global('HTTP_USER_AGENT');
$google_dt = time();
google_set_screen_res();
google_set_muid();
google_set_via_and_accept();
function read_global($var) { …Run Code Online (Sandbox Code Playgroud) 我正在研究这个:
<div id='container'>
<div id="box1">
<h1>Share it!</h1>
</div>
<div class="box" style="visibility: hidden">
<a href="#" class="bt btleft">Facebook Button here</a>
<a href="#" class="bt btright">Twitter Button here</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
$("#container").hover(function () {
$("#container div").css("visibility","visible");
},
function () {
$("#container div").css("visibility","hidden");
});
Run Code Online (Sandbox Code Playgroud)
我想要实现的是像Mashable这样的网站
我想要实现的是当我将鼠标悬停在"分享它!"这个词上时,它会自动隐藏并显示链接(在相同的位置).我被困在这里一段时间,有人可以帮忙吗?
我有一张图片就在这里:

我想在网站theverge.com上复制css样式(见下图)

我会在我的博客中(在主页面中)使用它,因为我试图复制theverge.com网站的内容.就像在半透明渐变和特色图像上使用帖子的标题和作者的名字一样.
请帮忙.
这是我的HTML的结构
http://jsfiddle.net/Kareen/kwPP8/2/
<div class="content">
<h3>Some Title Goes Here</h3>
<div>Author: Bill Jones</div>
<img src="http://lorempixel.com/300/200/nature/5" />
</div>
Run Code Online (Sandbox Code Playgroud) 所以我有这个功能,我想知道如何随机调用这两个函数.我的意思是,php代码会从两个中随机选择?我怎样才能做到这一点?
示例函数
function one() {
echo '
<div id="two-post">
<a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail('dos'); ?>
<div class="entry-meta">
<h1><?php the_title(); ?></h1>
<p>By <?php the_author(); ?></p>
</div>
<div class="overlay2"></div>
</a>
</div>
';
}
function two() {
echo '<div class="two">' . wp_trim_words( get_the_content(), 50, '' ) . '</div>';
}
function three() { // function names without "-"
echo '<div class="third">' . the_author() .'</div>';
}
Run Code Online (Sandbox Code Playgroud)
用于随机选择两个函数的代码
<?php
$functions = array('one', 'two', 'three'); // remove the open and …Run Code Online (Sandbox Code Playgroud) 我正在研究一个修改过的 wordpress 循环,其中有一个 if 和 else 条件。代码在下面。
我想要做的是添加一个容器,该容器将容纳满足条件的每个帖子。这将对每个条件进行分组。
<div class="container">
<?php if (have_posts()) : ?>
<?php
$i = 1;
while (have_posts()) {
the_post();
// Add a DIV CONTAINER that holds the FIRST CONDITION
if ($i <= 3) {
the_title();
the_content();
// Add a DIV CONTAINER that holds the FIRST CONDITION
// Add a DIV CONTAINER that holds the SECOND CONDITION
} elseif ($i <= 9) {
the_title();
the_permalink();
// Add a DIV CONTAINER that holds the SECOND CONDITION
// …Run Code Online (Sandbox Code Playgroud) 我想请你帮忙.
<div class="header-logo">
<a href="#"><img src="http://www.bendaggers.com/wp-content/themes/Anakin%20Skywalker/Images/BenDaggers%20Logo.PNG" /></a>
</div>
<div class="xbdlogo">
<img src="http://www.bendaggers.com/wp-content/themes/Anakin%20Skywalker/Images/Bendaggers%20Logo%20Two.PNG" />
</div>
Run Code Online (Sandbox Code Playgroud)
我想要做的是当你将徽标悬挂在"弯曲"上时,它旁边的小徽标将会改变它的css样式(从)顶部:-50px; 上:30px;
如果有人可以帮助我在javascript上这样做?谢谢!
这可能吗?
我有输入框和提交按钮.
分配的网址是:www.mywebsite.com/点击提交按钮后,通过javascript打开的网址是:www.mywebsite.com/print/hello123/
我有这个用于wordpress随机帖子插件的php代码:
<?php
global $post;
$tmp_post = $post;
$args = array( 'numberposts' => 5, 'orderby' => 'rand', 'post_status' => 'publish', 'offset' => 1);
$rand_posts = get_posts( $args );
foreach( $rand_posts as $post ) : ?>
<li><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2><p><?php the_excerpt(); ?>
</p></li>
<?php endforeach; ?>
</ul>
<?php $post = $tmp_post; // reset the $post to the original ?>
Run Code Online (Sandbox Code Playgroud)
我想知道代码的含义是什么'offset' => 1.我已经了解其他人如:
谁能为我定义这个.
对于某些人来说,这可能是一个初学者问题,但我无法解决这个问题:看,我拥有的是一个简单的文本框和提交按钮。文本框需要输入数字(应该是用户的工资)。每当我在任何浏览器中加载 php 文件时,都会出现此错误(见下图)。第 35 行的代码是什么?
$a = $_POST['salary'];
Run Code Online (Sandbox Code Playgroud)
我不知道这有什么问题...

<form method="POST">
Salary: <input id="salarytext" type="text" name="salary" onkeypress="return isNumberKey(event)"><br>
<input type="submit" />
</form>
<?php
$a = $_POST['salary'];
?>
<?php
switch($a) {
case ($a==""): echo "Input first your Compensation for the period!";
break;
case ($a < 1000 ): echo "Your Compensation is too low. You are not required to contribute for the period.";
break;
case ($a >=1000 && $a <=1249.99): echo "Your ER is 80.7 and Your EE is 33.30";
break;
case …Run Code Online (Sandbox Code Playgroud) php ×7
wordpress ×4
javascript ×3
if-statement ×2
adsense ×1
arrays ×1
containers ×1
css ×1
filter ×1
function ×1
gradient ×1
html ×1
jquery ×1
random ×1
show-hide ×1
url ×1
while-loop ×1