These are the good times in your life,
so put on a smile and it'll be alright
友链
导航
<?php $root = $_SERVER['DOCUMENT_ROOT']; chdir($root); $path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/'); set_include_path(get_include_path().':'.__DIR__); if(file_exists($root.$path)) { if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') $path = rtrim($path,'/').'/index.php'; if(strpos($path,'.php') === false) return false; else { chdir(dirname($root.$path)); require_once $root.$path; } }else include_once 'index.php';
可将此文件放到 WP 目录下,再 $ php -S localhost:9393 -t /path/to/wordpress router.php
运行
开发 theme / plugin 时, 应使用以下 plugins
wordpress(至少在 3.5 中)支持 2 种注册 widget 的方法:
模板中可通过自定义 page template 的方法自定义 page
Template Name
的注释, 该文件就会被当做一个 page template(post 没有 template, post 的类型是 format) <?php /* Template Name: Whatever */ ?>
用这个插件: WordPress › WordPress MU Domain Mapping « WordPress Plugins
在 root 站点使用以下 plugin:
<?php /** * @package My_Redirect * @version 0.1 */ /* Plugin Name: My Redirect Plugin URI: http://wordpress.stackexchange.com/questions/52298/hide-root-site-in-multisite-install */ add_action('template_redirect', 'wpse52298_redirect'); /* * Redirects all requests to the front end to another site * * * @uses wp_redirect */ function wpse52298_redirect() { // change this $to = 'http://www.example.com/'; wp_redirect(esc_url($to)); exit(); }
domain mapping - Hide root site in Multisite install - WordPress Answers
WordPress 数据库维护时常用到 12 个 SQL 语句
UPDATE 'wp_users' SET 'user_pass' = MD5('PASSWORD') WHERE 'user_login' ='admin' LIMIT 1;
UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID;
DELETE FROM wp_comments WHERE comment_approved = '0';
SELECT DISTINCT comment_author_email FROM wp_comments;
# 关闭留言: UPDATE wp_posts SET comment_status = 'closed' WHERE post_date < '2009-01-01' AND post_status = 'publish'; # 关闭Trackback: UPDATE wp_posts SET ping_status="closed" WHERE post_date < '2009-01-01' AND post_status = 'publish';
DELETE FROM wp_comments WHERE comment_author_url LIKE "%viagra%" ;
# 替换日志内容中字符串: UPDATE wp_posts SET post_content = REPLACE( post_content, 'string_to_find', 'string_to_replace' ) ; # 将某个留言者地址替换下: UPDATE wp_comments SET comment_author_url = REPLACE( comment_author_url, 'http://oldurl.com', 'http://newurl.com' ); # 留言者邮箱: UPDATE wp_comments SET comment_author_email = REPLACE( comment_author_email, 'old-email@address.com', 'new-email@address.com' ); # 还有一个 WordPress 插件 SEARCH & REPLACE 还提供一个后台让你更加容易进行批量替换。
UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';
DELETE a,b,c FROM wp_posts a WHERE a.post_type = 'revision' LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id); # 当然你还可以:彻底屏蔽日志修订功能。
SELECT * FROM wp_terms wt INNER JOIN wp_term_taxonomy wtt ON wt.term_id=wtt.term_id WHERE wtt.taxonomy='post_tag' AND wtt.count=0;
DELETE a,b,c FROM DATABASE.prefix_terms AS a LEFT JOIN DATABASE.prefix_term_taxonomy AS c ON a.term_id = c.term_id LEFT JOIN DATABASE.prefix_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE ( c.taxonomy = 'post_tag' AND c.count = 0 ); # 注:上面 SQL 除了删除标签,还删除了所有标签和标签和日志关联的关系。
SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
## A defined Virtual host NameVirtualHost *:80 <VirtualHost *:80> VirtualDocumentRoot /usr/share/wordpress/ ServerName blog.example.com ErrorLog /var/log/apache2/wp-error.log TransferLog /var/log/apache2/wp-access.log </VirtualHost> ## Without using Virtual host, hosted off /blog Alias /blog /usr/share/wordpress <Directory /usr/share/wordpress> Options FollowSymLinks AllowOverride Limit Options FileInfo DirectoryIndex index.php </Directory> # Tips If permalinks or rewrite is not working you might need: <Directory /> Options FollowSymLinks AllowOverride All </Directory> If NameVirtualHost *:80 is not working, you probably need to replace the * with the actual IP or hostname of your server.
/* Theme Name: Twenty Eleven Child Theme URI: http://example.com/ Description: Child theme for the Twenty Eleven theme Author: Your name here Author URI: http://example.com/about/ Template: twentyeleven Version: 0.1.0 */ @import url("../twentyeleven/style.css");
Posted on %A %B %e%q, %Y
, 至少到 2.5.32 仍存在的一个 bug 1), 解决方法如下:
wp-content/plugins/qtranslate/qtranslate_utils.php @@ -148,7 +148,10 @@ function qtrans_convertDateFormatToStrftimeFormat($format) { - $date_parameters[] = '#%#'; $strftime_parameters[] = '%%'; + $date_parameters[] = '#%#'; $strftime_parameters[] = '%';
allows multiple form inputs to be configured to search different aspects of a post including custom fields
, 但至少在 WP 3.5 以后不 work功能(能实现以 x 标记) | |||||
---|---|---|---|---|---|
插件 | caption | link | widget | 使用已上传的图片 | 备注 |
Nivo Slider for WordPress | x | x | 作者不再更新 | ||
Meteor Slides | x | x | x | ||
Easing Slider "Lite" | x | x |
$terms = get_terms( 'equipments', array('parent' => 9) ); # return null
: WordPress › Support » get_terms returning empty arrayAutomatic Update « Updating WordPress « WordPress Codex
自动更新需要注意 WP 的所有文件都得 owned and writeble by httpd user
Changing The Site URL « WordPress Codex
define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com');
mysql> update wp_options set option_value="http://example.com" where option_name like "siteurl" or option_name like "home";
修改后需注意 wp 目录中的 .htaccess, 有可能需要修改 RewriteBase 等配置.
Moving WordPress Multisite « Moving WordPress « WordPress Codex
UPDATE wp_site SET DOMAIN='new.example.com';
UPDATE wp_sitemeta SET meta_value='new.example.com' WHERE meta_key='siteurl';
UPDATE wp_blogs SET DOMAIN='new.example.com';
UPDATE wp_x_options SET option_value=REPLACE(option_value, 'old.example.com', 'new.example.com') WHERE option_value LIKE '%old.example.com%';
Does the problem occur for /wp-admin/ as well?
增加 post_type 后, 其下的某文章可按 URL 形如 http://example.com/product/%product_name%
访问到. 但尝试访问形如 http://example.com/product/
的链接确只能得到 404. 若想要访问
add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'acme_product', array( 'labels' => array( 'name' => __( 'Products' ), 'singular_name' => __( 'Product' ) ), 'public' => true, 'has_archive' => true, 'rewrite' => array('slug' => 'products') ) ); }
<ul class="submenu"> <? // here it's the query for my custom post type - Movies $querycp = array( 'post_type'=>'Movies','posts_per_page' => -1 ); query_posts($querycp); while (have_posts()) : the_post(); // here we check what's the post custom taxonomy, if it is the language we need $terms = get_the_terms(get_the_ID(), 'movies_cat'); foreach ( $terms as $term ) { $catref = $term->slug; } // if($catref=="english"): ?> <li><a href="<?=get_permalink()?>" title=""><?=get_the_title()?></a></li> <? endif; endwhile; ?> </ul>