有时候,我们需要连续发布同一个分类下的文章,每篇文章都要重新选择分类非常麻烦。下面,我们就用程序来搞定这个问题。

add_action('publish_post', 'save_fl' );
add_action('admin_footer-post.php', 'choose_a_category_before_publish');
add_action('admin_footer-post-new.php', 'choose_a_category_before_publish'); function save_fl($post_id)
{
if ( wp_is_post_revision( $post_id ) )
return; global $current_user;
update_option( 'default_fl_' . $current_user->ID , json_encode($_POST['post_category']) );
get_option('default_fl_' . $current_user->ID);
} function choose_a_category_before_publish(){
global $post_type;
global $current_user; $post_categorys = json_decode(get_option('default_fl_' . $current_user->ID), TRUE); if($post_type=='post'){
?>
<script>
jQuery(function($){
<?
if(count($post_categorys) > 0)
foreach($post_categorys as $post_category)
{?>
$("#in-category-<? echo $post_category; ?>").attr("checked","checked");
<?}
?>
});
</script><?
}
}

黄聪:wordpress自动选择上一篇文章选择的分类目录的更多相关文章

  1. 修改上一篇文章的node.js代码,支持调用自定义页面

    上一篇文章所有请求只能调用index.html,现在做个改造,允许调用自定义页面 服务端 app.js var app = require('http').createServer(handler) ...

  2. SMO是英文SQL Server Management Objects的缩写(上一篇文章的补充)

    最近在项目中用到了有关SQL Server管理任务方面的编程实现,有了一些自己的心得体会,想在此跟大家分享一下,在工作中用到了SMO/SQL CLR/SSIS等方面的知识,在国内这方面的文章并不多见, ...

  3. Wordpress上一篇文章和下一篇文章

    <div class="chapter"> <div class="prev"><?php previous_post_link( ...

  4. ASP.NET 实现上一篇文章 下一篇文章

    select top 1 * from job_hrnews where newsid>162  --下一篇 select top 1 * from job_hrnews where newsi ...

  5. 针对上一篇文章中的代码,想出的重构方案(python实现)

    #!/usr/bin/env python class Processor: def __init__(self, processor): self.processor = processor def ...

  6. 修改上一篇文章的node.js代码,支持默认页及支持中文

    服务端 app.js var app = require('http').createServer(handler) var io = require('socket.io')(app); var f ...

  7. 黄聪:Wordpress 模版技术手册 - WordPress Theme Technical manuals

    WordPress基本模板文件 一套完整的WordPress模板应至少具有如下文件: style.css : CSS(样式表)文件 index.php : 主页模板 archive.php : Arc ...

  8. Thinkphp 3.2中文章详情页的上一篇 下一篇文章功能

      额 简单2句话解释下 获取上一篇文章的原理,其实就是以当前文章的id为起点进行进行查询,例如id=5的文章 select * from article where (article_id<5 ...

  9. Android:学习AIDL,这一篇文章就够了(下)

    前言 上一篇博文介绍了关于AIDL是什么,为什么我们需要AIDL,AIDL的语法以及如何使用AIDL等方面的知识,这一篇博文将顺着上一篇的思路往下走,接着介绍关于AIDL的一些更加深入的知识.强烈建议 ...

随机推荐

  1. 百度APIStore

    链接 http://apistore.baidu.com/ 提供了许多免费的api接口,用来做功能性的查询

  2. JS初学之-选项卡(图片切换类)

    初学选项卡,主要问题卡在了索引值上面,花了较长的时间学习. 索引值其实很好理解,就是为每一个元素用JS的方法添加一个属性,即自定义属性. 在for循环里的函数里用i,会直接弹出这个数组的length, ...

  3. leetcode 126. Word Ladder II ----- java

    Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformat ...

  4. 1-1 Java简介

    主要内容: <1>Java平台应用 <2>核心概念:JVM.JDK.JRE <3>搭建Java开发环境 <4>使用工具开发Java程序 <5> ...

  5. URAL Mosaic(并查集)(欧拉回路)

    Mosaic Time limit: 0.25 secondMemory limit: 64 MB There's no doubt that one of the most important an ...

  6. 编码规范(一)之Code Templates的设置(转)

    编码规范(一)之Code Templates的设置 基于公司的主流开发工具为eclipse,但每个人都有自己的编码习惯,为了统一格式,这里通过三个方面:设置Code Templates.Checkst ...

  7. [转]GIT PUSH Error 403的解决方法

    http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-reques ...

  8. urllib,urllib2,requests对比

    #coding:utf-8 import urllib2 import urllib import httplib import socket import requests #实现以下几个方面内容: ...

  9. Java设计模式之工厂设计模式

    工厂模式(Factory Method):定义一个用于创建对象的接口,让子类决定实例化哪一个类.工厂方法使一个类的实例化延迟到了子类. 1.业务逻辑 1.1.父类Operation package c ...

  10. (转)Attention

        本文转自:http://www.cosmosshadow.com/ml/%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/2016/03/08/Attention.ht ...