Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

3D

INTERN

ADOBE

ARDUINO

BITBUCKET

DOCKER

C4D

GIT

HTML

IPHONE

JAVASCRIPT

JTL-SHOP

LARAVEL

MAGENTO2

MYSQL

PHP

PLESK

PROCESSING

PYTHON

SUITECRM

SEO

TRYTON

THUNDERBIRD / ICEDOVE / FossaMail

TYPO3

TYPO3: BACKEND

TYPO3: TYPOSCRIPT

UNIX

VLC

VVVV

WINDOWS

WINDOWS 10

WORDPRESS

XAMPP

XT:C 4 (Veyton)

wordpress-piklist-cheatsheet

piklist-small-cheatsheet

Meta Boxes

Doc regarding possible fields

:!: Achtung: beim Einsatz mit W3 Total Cache object cache abschalten

text

set fields

piklist('field', array(
    'type' => 'text',
    'field' => 'demo_text',
    'label' => 'Text Box',
    'description' => 'Field Description',
    'value' => 'Default text',
    'help' => 'This is help text.'
    'attributes' => array(
      'class' => 'text'
    )
  ));
$video_url = get_post_meta(get_the_ID(), 'video_embed', true);
echo wp_oembed_get($video_url);

get values

echo get_post_meta(get_the_ID(), 'demo_text', true);

image-upload

set field

piklist('field', array(
  'type' => 'file',
  'field' => 'my_image',
  'label' => 'Upload image'
));

Hint: if you set 'type' to '_thumbnail_id' you get a sortable filed and multiple post_images

get value

$image_ids = get_post_meta($post->ID, 'my_image');
 
foreach ($image_ids as $image)
{
  $myupload = get_post($image); 
  $title = $myupload->post_title;
  $description = $myupload->post_content;
  $caption = $myupload->post_excerpt;
 
  echo 'title:' . $title;
  echo 'description:' . $description;
  echo 'caption:' . $caption;
 
 echo '<img src="' . wp_get_attachment_url($image) . '"/>';
 
  print_r($myupload); // Displays all data
}

editor field

set field

<?php
  piklist('field', array(
    'type' => 'editor'
    ,'scope' => 'post'
    ,'field' => 'field_name'
    ,'label' => __('Example Field')
    ,'description' => __('This is a description of the field.')
    ,'value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
    ,'options' => array (
      'wpautop' => true
      ,'media_buttons' => true
      ,'tabindex' => ''
      ,'editor_css' => ''
      ,'editor_class' => ''
      ,'teeny' => false
      ,'dfw' => false
      ,'tinymce' => true
      ,'quicktags' => true
    )
  ))?>

:!: additional editor fields need scope ='post_meta'

get field

echo wpautop( get_post_meta( get_the_ID(), 'field_name', true ) );

remove native editor field

removal from post wich use 'my-template.php' as Template.. place it in functions.php of theme

add_action( 'admin_init', 'hide_editor' );
 
function hide_editor() {
 
	// Get the Post ID.
	if ( isset ( $_GET['post'] ) )
		$post_id = $_GET['post'];
	else if ( isset ( $_POST['post_ID'] ) )
		$post_id = $_POST['post_ID'];
 
	if( !isset ( $post_id ) || empty ( $post_id ) )
		return;
 
	// Get the name of the Page Template file.
	$template_file = get_post_meta($post_id, '_wp_page_template', true);
 
	if($template_file == 'page-aboutme.php'){ // edit the template name
		remove_post_type_support('page', 'editor');
	}
 
}
wordpress-piklist-cheatsheet.txt · Zuletzt geändert: 2015/09/24 07:37 von admin