mwdelaney/acf-complex-titles

此包已被废弃,不再维护。没有建议的替代包。

使用Advanced Custom Fields Pro 5为WordPress内容类型创建具有预览的复杂标题。

安装次数: 1,758

依赖项: 0

建议者: 0

安全: 0

星标: 46

关注者: 1

分支: 2

开放问题: 1

类型:wordpress-plugin

1.16 2018-06-06 14:00 UTC

This package is auto-updated.

Last update: 2021-10-14 23:32:53 UTC


README

一个WordPress插件,用于添加自定义字段以创建格式化标题

此插件在标题页面下方创建自定义字段,并在循环内部调用时自动替换the_title()

Screenshot

要求

  1. WordPress 4.5+
  2. Advanced Custom Fields Pro 5

使用

目前包括以下格式化选项

  1. 单词或短语(实际内容,不要删除此选项)
  2. 强调
  3. 大小(小、中、大)
  4. 对齐(左、右、居中)

以下布局也适用于标题组

  1. 对齐

添加字段

要将字段添加到标题,请按如下方式扩展Fields类

	 // Replace the plugin's Fields class with our class extending it
	 add_filter ('acfct_set_fields_class',  function() { return 'myFields'; });

	 // Add custom CSS to style the new fields
	 add_action ('complex_titles_css', 'addMyStyles');

	 /**
	  * Add styling for the new fields
	  * 	Naming scheme is as follows:
	  * 		.complex-title-element-[your-field-acf-name]
	  */
	 
	 function addMyStyles() {
		 // Variable containing the styles we want to add
		 $myStyles = "
		 	.complex-title-element-underline {
				text-decoration: underline;
			}
		 ";
		 
		 // Enqueue these styles along with the plugin's other styles
		 wp_add_inline_style( 'acf-complex-titles-style', $myStyles );
	 }

	 // Our class extending the plugin's class to add new fields
	 class myFields extends MWD\ComplexTitles\Fields {
		 /**
 		 * Field: Underline
 		 *
 		 * @author Michael W. Delaney
 		 * @since 1.0
 		 *
 		 * Checkbox
 		 */
 		public $underline = array (
 			'order' => '10',
 			'field' => array (
 				'key' => 'acfct_underline',
 				'label' => 'Underline',
 				'name' => 'underline',
 				'type' => 'true_false',
 			)
 		);
	 }

仅启用一些字段

要从可用列表中删除字段,仅声明主题对所需字段的本地化支持

add_theme_support( 'complex-titles-fields', array( 'word-or-phrase', 'size' ) );

仅启用一些布局

要从可用列表中删除布局,仅声明主题对所需布局的本地化支持

add_theme_support( 'complex-titles-layout', array( 'alignment' ) );

更改哪些帖子类型获得复杂标题

默认情况下,复杂标题已启用页面,要定义复杂标题应可用的帖子类型,请声明主题支持

 $landing_page_templates = array(
   array (
     array (
       'param' => 'post_type',
       'operator' => '==',
       'value' => 'page',
     ),
     array (
       'param' => 'page_template',
       'operator' => '!=',
       'value' => 'template-no-header-image.php',
     ),
   ),
 );
 add_theme_support( 'complex-titles-location', $landing_page_templates );

模板

包括基本模板和样式。这些模板设计用于通过您的主题进行简单样式化。要覆盖包含的模板,请将模板(您要覆盖的模板)从templates复制到您的主题中的子目录ct-templates

样式

此插件带有默认字段的默认样式。这些样式在前端和WordPress管理界面中排队,以便Complex Title预览区域尽可能接近前端。要取消排队这些样式并用您自己的替换,请将以下内容添加到functions.php

remove_action('complex_titles_css', array( $acf_complex_titles, 'front_end_styles' ) );