function ingredients_meta() {
add_meta_box( 'ingredients_meta',
__('Ингредиенты'),
'ingredients_meta_callback',
'recipes',
'advanced',
'default' );
}
add_action('add_meta_boxes', 'ingredients_meta');
function ingredients_meta_callback( $post ) {
echo _e('<p>Требуемые Ингредиенты для приготовления</p>');
wp_nonce_field( basename(__FILE__), 'ingredients_nonce');
$ingredients_stored_meta = get_post_meta( $post->ID );
wp_editor($ingredients_stored_meta['ingredients-recipes-original'][0], 'ingredients-recipes-original', array(
'wpautop' => 1,
'media_buttons' => 1,
'textarea_name' => 'ingredients-recipes-original', //нужно указывать!
'textarea_rows' => 20,
'tabindex' => null,
'editor_css' => '',
'editor_class' => '',
'teeny' => 0,
'dfw' => 0,
'tinymce' => 1,
'quicktags' => 1,
'drag_drop_upload' => false
) );
}
function ingredients_meta_save( $post_id ) {
// Checks save status
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST[ 'ingredients_nonce' ] ) && wp_verify_nonce( $_POST[ 'ingredients_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
// Exits script depending on save status
if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
return;
}
// Checks for input and sanitizes/saves if needed
if( isset( $_POST[ 'ingredients-recipes-original' ] ) ) {
update_post_meta( $post_id, 'ingredients-recipes-original', $_POST[ 'ingredients-recipes-original' ] );
}
}
add_action( 'save_post', 'ingredients_meta_save' );
Тоже столкнулся с данной проблемой и решение оказалось гораздо проще. При создании произвольного типа записи нужно разрешить пагинацию. По ключю 'rewrite' у меня значение 'pages' стояло в false и при переходе на site.ru/courses/page/2 выдавало 404 страницу. Исправил на true, обновил настройку постоянных ссылок в админке и все заработало.
$courses = array(
/***/
'capability_type' => 'post',
'rewrite' => array(
'slug' => 'courses/%coursescat%',
'with_front' => false,
'pages' => true,
'feeds' => false,
'feed' => false
),
'has_archive' => 'courses',
/****/
);
register_post_type( 'courses', $courses );
$image_url = wp_get_attachment_image_url( $image, 'full' );
<div class="vc-infobox-image"><img src="' . $image_url . '"></div>
<?php
/*
Element Description: VC image Box
*/
// Element Class
class vcimageBox extends WPBakeryShortCode {
// Element Init
function __construct() {
add_action( 'init', array( $this, 'vc_imagebox_mapping' ) );
add_shortcode( 'vc_imagebox', array( $this, 'vc_imagebox_html' ) );
}
// Element Mapping
public function vc_imagebox_mapping() {
// Stop all if VC is not enabled
if ( !defined( 'WPB_VC_VERSION' ) ) {
return;
}
// Map the block with vc_map()
vc_map(
array(
'name' => __('VC Imagebox', 'text-domain'),
'base' => 'vc_imagebox',
'description' => __('Another simple VC box', 'text-domain'),
'category' => __('Stimul', 'text-domain'),
'icon' => get_template_directory_uri().'/inc/image/Logo.png',
'params' => array(
array(
'type' => 'textfield',
'holder' => 'h3',
'class' => 'title-class',
'heading' => __( 'Title', 'text-domain' ),
'param_name' => 'title',
'value' => __( 'Default value', 'text-domain' ),
'description' => __( 'Box Title', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'attach_image',
'holder' => 'div',
'class' => 'image-class',
'heading' => __('Side Image', 'wpcentral'),
'param_name' => 'image',
'description' => __('The Image in the background', 'wpcentral')
),
array(
'type' => 'textfield',
'holder' => 'div',
'class' => 'text-class',
'heading' => __( 'Price', 'text-domain' ),
'param_name' => 'price',
'value' => __( 'Default value', 'text-domain' ),
'description' => __( 'Box Text', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'textfield',
'holder' => 'div',
'class' => 'text-class',
'heading' => __( 'Text desc', 'text-domain' ),
'param_name' => 'text',
'value' => __( 'Default value', 'text-domain' ),
'description' => __( 'Box Text', 'text-domain' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
array(
'type' => 'textfield',
'holder' => 'div',
'class' => 'card-button-card',
'heading' => __( 'text-Button', 'text-button' ),
'param_name' => 'button',
'value' => __( 'Default value', 'button-text-domain' ),
'description' => __( 'Box button', 'text-button' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
) ,
array(
'type' => 'textfield',
'holder' => 'div',
'class' => 'card-button-URL',
'heading' => __( 'URL', 'text-button-URL' ),
'param_name' => 'url',
'value' => __( 'Default value', 'button-text-domain' ),
'description' => __( 'Box button url', 'text-url' ),
'admin_label' => false,
'weight' => 0,
'group' => 'Custom Group',
),
)
)
);
}
// Element HTML
public function vc_imagebox_html( $atts ) {
// Params extraction
extract(
shortcode_atts(
array(
'title' => '',
'text' => '',
'button' => '',
'price' => '',
'url' => '',
'image' => '',
),
$atts
)
);
$image_url = wp_get_attachment_image_url( $image, 'full' );
// Fill $html var with data
$html = '
<div class="vc-infobox-wrap">
<div class="row">
<div class="col-md-12">
<div class="vc-infobox-title">' . $title . '</div></div>
<div class="image"> ' . $image . '</div>
<div class="vc-infobox-image"><img src="' . $image_url . '"></div>
<div class="col-md-6"> <div class="vc-infobox-price">' . $price . '</div>
<div class="vc-imagebox-text">' . $text . '</div></div>
<div class="col-md-6"><div class="vc-infobox-button"><a class="card-button-card" href="' . $url . '">' . $button . '</a></div></div>
</div>
</div>';
return $html;
}
} // End Element Class
// Element Class Init
new vcimageBox();