- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用带有高级自定义字段的自定义帖子类型来创建帖子的自定义条目。我的海关邮政类型和选项添加了(请滚动代码框查看全部):
add_action( 'init', 'register_cpt_campaigns' );
function register_cpt_campaigns() {
$labels = array(
'name' => __( 'Campaigns', 'campaigns' ),
'singular_name' => __( 'campaign', 'campaigns' ),
'add_new' => __( 'Add New', 'campaigns' ),
'add_new_item' => __( 'Add New Campaign', 'campaigns' ),
'edit_item' => __( 'Edit Campaign', 'campaigns' ),
'new_item' => __( 'New Campaign', 'campaigns' ),
'view_item' => __( 'View Campaign', 'campaigns' ),
'search_items' => __( 'Search Campaigns', 'campaigns' ),
'not_found' => __( 'Campaign not found', 'campaigns' ),
'not_found_in_trash' => __( 'Campaign not found', 'campaigns' ),
'parent_item_colon' => __( 'Parent campaign:', 'campaigns' ),
'menu_name' => __( 'Campaigns', 'campaigns' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'Custom post type for Discovr Campaigns',
'supports' => array( 'author','title' ),
'taxonomies' => array( 'campaign_category', 'campaign_action' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-welcome-widgets-menus',
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => false,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'campaigns', $args );
}
自定义分类法(请滚动代码框查看全部):
// Register Campaign Type Taxonomy
function campaign_post_category() {
$labels = array(
'name' => _x( 'Campaign Types', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Campaign Type', 'Taxonomy Singular Name', 'text_domain' ),
'menu_name' => __( 'Campaign Types', 'text_domain' ),
'all_items' => __( 'All types', 'text_domain' ),
'parent_item' => __( 'Parent types', 'text_domain' ),
'parent_item_colon' => __( 'Parent types:', 'text_domain' ),
'new_item_name' => __( 'New Campaign Type', 'text_domain' ),
'add_new_item' => __( 'Add New Campaign Type', 'text_domain' ),
'edit_item' => __( 'Edit Campaign Type', 'text_domain' ),
'update_item' => __( 'Update Campaign Type', 'text_domain' ),
'view_item' => __( 'View Campaign Type', 'text_domain' ),
'separate_items_with_commas' => __( 'Separate campaign types with commas', 'text_domain' ),
'add_or_remove_items' => __( 'Add or remove campaign types', 'text_domain' ),
'choose_from_most_used' => __( 'Choose from the most used', 'text_domain' ),
'popular_items' => __( 'Popular campaign types', 'text_domain' ),
'search_items' => __( 'Search campaign type', 'text_domain' ),
'not_found' => __( 'Not Found', 'text_domain' ),
'no_terms' => __( 'No campaign types', 'text_domain' ),
'items_list' => __( 'Campaign type list', 'text_domain' ),
'items_list_navigation' => __( 'Campaign type list navigation', 'text_domain' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => false,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
);
register_taxonomy( 'campaign_category', array( 'campaign_categories' ), $args );
}
add_action( 'init', 'campaign_post_category', 0 );
// Register Campaign Status Taxonomy
function campaign_post_action() {
$labels = array(
'name' => _x( 'Campaign Status', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Campaign Status', 'Taxonomy Singular Name', 'text_domain' ),
'menu_name' => __( 'Campaign Status', 'text_domain' ),
'all_items' => __( 'All Status', 'text_domain' ),
'parent_item' => __( 'Parent Status', 'text_domain' ),
'parent_item_colon' => __( 'Parent Status:', 'text_domain' ),
'new_item_name' => __( 'New Campaign Status', 'text_domain' ),
'add_new_item' => __( 'Add New Campaign Status', 'text_domain' ),
'edit_item' => __( 'Edit Campaign Status', 'text_domain' ),
'update_item' => __( 'Update Campaign Status', 'text_domain' ),
'view_item' => __( 'View Campaign Status', 'text_domain' ),
'separate_items_with_commas' => __( 'Separate campaign status with commas', 'text_domain' ),
'add_or_remove_items' => __( 'Add or remove campaign status', 'text_domain' ),
'choose_from_most_used' => __( 'Choose from the most used', 'text_domain' ),
'popular_items' => __( 'Popular campaign status', 'text_domain' ),
'search_items' => __( 'Search campaign status', 'text_domain' ),
'not_found' => __( 'Not Found', 'text_domain' ),
'no_terms' => __( 'No campaign status', 'text_domain' ),
'items_list' => __( 'campaign status list', 'text_domain' ),
'items_list_navigation' => __( 'campaign status list navigation', 'text_domain' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'public' => true,
'show_ui' => false,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
);
register_taxonomy( 'campaign_action', array( 'campaign_actions' ), $args );
}
add_action( 'init', 'campaign_post_action', 0 );
我还有一些功能被添加到主题中以支持我的post-type
功能。我已删除这些以纠正我的问题,但没有解决任何问题。
// Add Default Campaign Status
function set_default_campaign_status( $post_id, $post ) {
if ( 'publish' === $post->post_status && $post->post_type === 'campaigns' ) {
$defaults = array(
'campaign_action' => array( 'Draft' )
);
$taxonomies = get_object_taxonomies( $post->post_type );
foreach ( (array) $taxonomies as $taxonomy ) {
$terms = wp_get_post_terms( $post_id, $taxonomy );
if ( empty( $terms ) && array_key_exists( $taxonomy, $defaults ) ) {
wp_set_object_terms( $post_id, $defaults[$taxonomy], $taxonomy );
}
}
}
}
add_action( 'save_post', 'set_default_campaign_status', 0, 2 );
// Add Default Campaign Type
function set_default_campaign_type( $post_id, $post ) {
if ( 'publish' === $post->post_status && $post->post_type === 'campaigns' ) {
$defaults = array(
'campaign_category' => array( 'Not Selected' )
);
$taxonomies = get_object_taxonomies( $post->post_type );
foreach ( (array) $taxonomies as $taxonomy ) {
$terms = wp_get_post_terms( $post_id, $taxonomy );
if ( empty( $terms ) && array_key_exists( $taxonomy, $defaults ) ) {
wp_set_object_terms( $post_id, $defaults[$taxonomy], $taxonomy );
}
}
}
}
add_action( 'save_post', 'set_default_campaign_type', 0, 2 );
// Delete post
function delete_post(){
global $post;
$deletepostlink= add_query_arg( 'frontend', 'true', get_delete_post_link( get_the_ID() ) );
if (current_user_can('edit_post', $post->ID)) {
echo '<a href="'.$deletepostlink.'" id=""><button class="m-t-10 m-b-10 btn btn-danger btn-cons" type="button">Delete</button></a>';
}
}
//Redirect after delete post in frontend
add_action('trashed_post','trash_redirection_frontend');
function trash_redirection_frontend($post_id) {
if ( filter_input( INPUT_GET, 'frontend', FILTER_VALIDATE_BOOLEAN ) ) {
wp_redirect( get_option('siteurl').'/campaigns' );
exit;
}
}
// Add default Campaign Pages
function discovr_campaign_endpoints() {
add_rewrite_endpoint( 'overview', EP_PERMALINK );
add_rewrite_endpoint( 'new-campaign-details', EP_PERMALINK );
add_rewrite_endpoint( 'new-campaign-audience', EP_PERMALINK );
add_rewrite_endpoint( 'new-campaign-page', EP_PERMALINK );
add_rewrite_endpoint( 'new-campaign-ads', EP_PERMALINK );
add_rewrite_endpoint( 'edit-campaign', EP_PERMALINK );
add_rewrite_endpoint( 'analytics', EP_PERMALINK );
}
add_action( 'init', 'discovr_campaign_endpoints' );
// Update Campaign Page on Save
add_action( 'save_post', 'wpse105926_save_post_callback' );
function wpse105926_save_post_callback( $post_id ) {
// verify post is not a revision
if ( ! wp_is_post_revision( $post_id ) ) {
// unhook this function to prevent infinite looping
remove_action( 'save_post', 'wpse105926_save_post_callback' );
// update the post slug
wp_update_post( array(
'ID' => $post_id,
'post_name' => '' // do your thing here
));
// re-hook this function
add_action( 'save_post', 'wpse105926_save_post_callback' );
}
}
// Add Campaign Title Label and Instuctions
function my_acf_prepare_field( $field ) {
$field['label'] = "Campaign Title";
$field['instructions'] = "Internal use only. Ex: `Retarget Abandoned Bookings`";
return $field;
}
add_filter('acf/prepare_field/name=_post_title', 'my_acf_prepare_field');
不幸的是,每次我保存自定义字段时,它都会恢复为空或原始状态。这仅发生在 ACF 字段中,而不会发生在未被 ACF 覆盖的标题、作者或分类法等字段中。请查看以下 gif 图像以进一步了解。
我已经尝试删除所有前端功能,但在后端仍然不起作用,还删除了除 ACF 之外的所有插件。调试或 Firebug 中没有错误。我只能想象字段之间存在冲突,或者 ACF 无法找到合适的位置来保存这些字段。
非常感谢任何帮助,我希望我错过了一些简单的事情。
更新
这通过将 field_name
和 field_label
更改为模糊的东西来实现。
让它现在工作很好,但是,我需要 field_label
和 field_name
来匹配这些字段的用途。我可以在 functions.php
中覆盖这些,但这将是一场噩梦,因为我们可能要添加 20 个字段。
最佳答案
如果您将 field_label 更改为此事件的目的,并将 field_name 更改为 what_is_the_purpose_of_this_campaign,则它不起作用。
但是,如果您将 field_label` 更改为 whatisthepurposeofthiscampaign 并将 field_name 更改为 whatisthepurposeofthiscampaign 它确实有效。
似乎任何空格都会破坏 field_label 和 field_name 的连接
关于php - Wordpress 插件 Advanced Custom Fields Pro 不保存前端和后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46088529/
我在大学学习C++时学习了这段代码..后来我在C#中使用了同样的东西...但现在我想在Java中使用它...我在互联网上寻找类似的东西,但我什至不知道如何表达它,以便我得到正确的结果。 所以嗯,请让我
我正在我的 Ruby on Rails Controller 上运行 RSPEC 测试,这是我正在测试的 Controller 操作: Controller 代码: class Customers::
想为我选择的选项卡设置自定义背景,到目前为止,子类化是我自定义 UITAbBar/UITabBarItem 的方式。 问题是:有谁知道(或知道我在哪里可以找到)设置背景的属性是什么? 所选选项卡周围有
您好,我在 commerefacades-beans.xml 中创建了 eProductForm bean,我添加了 ProductData 的自定义属性。 然后在commercewebs
我有两个表:1. 客户2. customer_order 客户表包含客户数据(duh),customer_order 包含所有订单。我可以在 customer.id=customer_order.id
在我的 TableView 中,我有一个 NSMutableArray *currList 的数据源 - 它包含对象 Agent 的对象。我创建了自定义的 TableCell 并正确设置了所有内容。我
是否建议使用自引用泛型继承? public abstract class Entity { public Guid Id {get; set;} public int Version
我正在尝试为我的 Grafana 安装使用自定义文件 ( custom.ini )。不幸的是,这不起作用。 我做了什么: 安装了一台装有 CentOS 7 的虚拟机 添加了 Grafana Yum R
我被分配了两个给定类的作业,一个是抽象父类 Lot.java,另一个是测试类 TestLots.java。我不应该编辑其中任何一个。任务是创建Lot的两个子类,使TestLots中的错误不再是错误。
我是 Botpress 的新手。 我刚刚安装了 Botpress 的最新版本“botpress-ce-v11_0_1-win-x64”。 我浏览了文档,发现了一些关于内容类型、内容元素和内容渲染的解释
我一直在四处寻找,但我还没有找到任何东西,除了 Qt3 的旧文档和 qt 设计器的 3.x 版。 我会举个例子,并不是因为我的项目是 GPL 而不能提供代码,而是为了简单起见。 示例:您正在为您的应用
场景 我有一个自定义规则来验证订单的运费: public class OrderValidator : BaseValidator { private string CustomInfo {
我有用于身份验证的自定义拦截器: @Named("authInterceptor") @Provides @Singleton fun providesAuthIntercep
如果有人没有添加照片,我想显示默认头像图像。我假设我需要在模型或助手中执行自定义 getter。 如果我做 getter,它会看起来像这样吗: def avatar_url "default_ur
我正在使用 Google Search API,但遇到了一些麻烦。这个请求(在 Python 中,使用 requests 库)工作正常 res = requests.get("https://www.
我使用 MSKLC 制作了自定义键盘布局。 我以为我仔细按照说明操作了chose appropriate values对于LOCALENAME和 LOCALID参数。 但是,在通过按 Win+Spac
我正在使用 simpleframework解析 XML 字符串并将其转换为对象。 Serializer serializer = new Persister(); try { Customer
我正在使用 C# 控制台应用程序从 MySql 数据库获取一些数据,但在正确查询时遇到一些问题 现在的情况: SELECT * FROM Customer WHERE EXISTS ( SELECT
我在我的 iPhone 4S 上运行我的应用程序,我正在使用自定义表格 View Controller 和自定义表格 View 单元格,当我将表格 View 向上滑动到空白区域并同样向下滑动到空白区域
我有一个自定义的 JavaScript 变量,它正在检查 eventAction 是什么,这样我就可以知道是否触发一些转换像素。自定义 Javascript 称为“FacebookConversion
我是一名优秀的程序员,十分优秀!