Author: 迎迎 姚

  • Add Custom Post Type Columns for wordpress

    Add Custom Post Type Columns for wordpress

    这儿以 costom post portfolio 为例, 为 portfolio 列表页加上 两个分类列。删除时间列。 add_filter( ‘manage_edit-portfolio_columns’, ‘set_custom_edit_portfolio_columns’ ); add_action( ‘manage_portfolio_posts_custom_column’ , ‘custom_portfolio_column’, 10, 2 ); function set_custom_edit_portfolio_columns($columns) { unset($columns[‘date’]); //注销不需要的列 return $columns + array(‘portfolio_category’ => __(‘Categories’),’client_category’=>’Client Terms’); } function custom_portfolio_column( $column, $post_id ) { switch ( $column ) { case ‘portfolio_category’: $terms = get_the_term_list( $post_id , ‘portfolio_category’ , ” ,…

  • icl_link_to_element and icl_object_id

    icl_link_to_element and icl_object_id

    Example usage Example Purpose Produced HTML <?php icl_link_to_element(10); ?> Link to page 10 (support page) <a href=”/support/”>Support</a> <?php icl_link_to_element(10,’post’,__(‘Get help’)); ?> Link to support page with an alternative link text <a href=”/support/”>Get help</a> <?php icl_link_to_element(10,’post’,false, array(‘category’=>’products’,’priority’=>’high’); ?> Link to support page and add two arguments <a href=”/support/?category=products&amp;priority=high”>Support</a> <?php icl_link_to_element(10,’post’,false,’priority’=>’high’,’faq’); ?> <?php icl_link_to_element(3,’tag’); ?> Link to…

  • 修改WordPress里用户页的联系信息(Contact Info)

    修改WordPress里用户页的联系信息(Contact Info)

    新旧界面对比,旧界面中的 aim,jabber,yim 被去掉了,加入了时下大家最熟悉的 facebook,twitter …… add_filter( ‘user_contactmethods’ , ‘update_contact_methods’ , 10 , 1 ); function update_contact_methods( $contactmethods ) { // Add new fields $contactmethods[‘phone’] = ‘Phone’; $contactmethods[‘mobile’] = ‘Mobile’; $contactmethods[‘address’] = ‘Address’; // Remove annoying and unwanted default fields unset($contactmethods[‘aim’]); unset($contactmethods[‘jabber’]); unset($contactmethods[‘yim’]); return $contactmethods; }

  • WPML Coding API and Custom Language Switcher

    WPML Coding API and Custom Language Switcher

    老是打不开这些页面,干脆复制到自己的地盘来了。方便自己也方便大家。 神马?WPML 是啥,自己百度吧! WPML offers functions that can be used in your WordPress theme to provide correct support for multilingual themes. Function Purpose Notes do_action(‘icl_language_selector’) Insert the drop down language selector. Described in the language setup section of the getting started guide. do_action(‘icl_navigation_menu’) Insert the top navigation menu. Described in the navitaionsection of the getting started guide. do_action(‘icl_navigation_breadcrumb’)…

  • WordPress debug code

    WordPress debug code

    WordPress debug 代码,把它放在function 文件里,就会在每页的页脚出现这个,包括当前模板,重写规则,Query 等等。 add_action( ‘template_include’, ‘_childtheme_print_template_name’ ); function _childtheme_print_template_name( $template_name ) { global $childtheme_template_name; $childtheme_template_name = $template_name; add_action( ‘wp_footer’, ‘childtheme_print_template_name’, 100 ); return $template_name; } function childtheme_print_template_name( ) { global $childtheme_template_name, $wp_query, $wp_options; echo ” <div style=’padding-left:50px’> DEBUG INFO: Active Template: “.$childtheme_template_name.”\n”; childtheme_print_matched_rewrite_rule(); echo ‘posts_per_page (default option) = ‘.get_option( ‘posts_per_page’ ).”\n”; echo “\n\nWP_QUERY:…

  • Contact Form 7 的那些事儿

    http://hypercircle.com/customization-of-contact-form-7-plugin.html Additional headers:You can input any header lines into the field and you can insert any tags into any place in each header line, just like other Mail fields. Viz: CC, BCC etc like this: After the form is submitted the viewer is able to see the response messages such as “Your message was sent…

  • php数组随机排序

    php数组随机排序

    $array = array(‘A’,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’10’,’J’,’Q’,’K’); shuffle($array); //随机排序数组 print_r($array); //输出数组

  • WordPress 获取附件图片时去除特色图片

    WordPress 获取附件图片时去除特色图片

    获取一篇文章中上传的所有图片,但是不包括 特色图片: ?>

  • WordPress Portfolio work with Isotope and Infinite Scroll

    WordPress Portfolio work with Isotope and Infinite Scroll

    准备:需要的jQuery插件 Isotope: 神奇的布局精致的jQuery插件。演示 Infinite Scroll:无限滚动被称为autopagerize的,unpaginate,无尽的网页。但实质上,它是预取从随后出现的页面上的内容,并直接将其添加到用户的当前页面。http://www.infinite-scroll.com/ 演示 新建文章类型 portfolio 和 Portfolio 分类  function my_post_types() { register_post_type(‘portfolio’, array( ‘label’ => __(‘Portfolio’,’itc’), ‘singular_label’ => __(‘Portfolio’, ‘itc’), ‘_builtin’ => false, //’exclude_from_search’ => false, // Exclude from Search Results ‘capability_type’ => ‘post’, ‘public’ => true, ‘show_ui’ => true, ‘show_in_nav_menus’ => FALSE, ‘menu_position’ => 100, ‘rewrite’ => array( ‘slug’ => ‘portfolio-show’, ‘with_front’ => FALSE,…

  • Get Featured Image with timthumb

    Get Featured Image with timthumb

    $w = ‘350’; $h = ‘200’; if (has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), ‘full’); echo ”; } else { echo ”; }