안녕 내가 플러그인에 단축 코드를 사용하지만이에 붙어 오전하는 방법 운동에 노력하고 있어요 .. 그 내가 http://www.wpbeginner.com/wp-tutorials/how-to-add-rotating-testimonials-in-wordpress/워드 프레스 단축 코드 문제가
조금 작동하지만 코드를 출력하지 않습니다에서 발견 플러그인 왜 이런 일이 일어나고 있는지 정확하게 알지 못합니다. 나는이 별도의 파일을 추가 할 것 같은
나는
어떤 도움도 큰 것입니다 .. 코드를 업그레이드하고, CSS 및 JQuery와 코드를 제거했습니다! 당신이 Shortcode API 보면
<?php
/*
Plugin Name: Shortcode test
Version: 0.1
Plugin URI: http://www.websiteplugin.com/
Description: Adding theatre edits to the resume page
Author: Auther name
Author URI: http://www.websiteauther.com/
*/
add_action('init', 'wpb_register_cpt_testimonial');
function wpb_register_cpt_testimonial() {
$labels = array(
'name' => _x('Testimonials', 'testimonial'),
'singular_name' => _x('testimonial', 'testimonial'),
'add_new' => _x('Add New', 'testimonial'),
'add_new_item' => _x('Add New testimonial', 'testimonial'),
'edit_item' => _x('Edit testimonial', 'testimonial'),
'new_item' => _x('New testimonial', 'testimonial'),
'view_item' => _x('View testimonial', 'testimonial'),
'search_items' => _x('Search Testimonials', 'testimonial'),
'not_found' => _x('No testimonials found', 'testimonial'),
'not_found_in_trash' => _x('No testimonials found in Trash', 'testimonial'),
'parent_item_colon' => _x('Parent testimonial:', 'testimonial'),
'menu_name' => _x('Testimonials', 'testimonial'),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields', 'revisions'),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type('testimonial', $args);
}
$key = "testimonial";
$meta_boxes = array(
"person-name" => array(
"name" => "person-name",
"title" => "Person's Name",
"description" => "Enter the name of the person who gave you the testimonial."),
"position" => array(
"name" => "position",
"title" => "Position in Company",
"description" => "Enter their position in their specific company."),
"company" => array(
"name" => "company",
"title" => "Company Name",
"description" => "Enter the client Company Name"),
"link" => array(
"name" => "link",
"title" => "Client Link",
"description" => "Enter the link to client's site, or you can enter the link to your portfolio page where you have the client displayed.")
);
function wpb_create_meta_box() {
global $key;
if(function_exists('add_meta_box')) {
add_meta_box('new-meta-boxes', ucfirst($key) . ' Information', 'display_meta_box', 'testimonial', 'normal', 'high');
}
}
function display_meta_box() {
global $post, $meta_boxes, $key;
?>
<div class="form-wrap">
<?php
wp_nonce_field(plugin_basename(__FILE__), $key . '_wpnonce', false, true);
foreach($meta_boxes as $meta_box) {
$data = get_post_meta($post->ID, $key, true);
?>
<div class="form-field form-required">
<label for="<?php echo $meta_box[ 'name' ]; ?>"><?php echo $meta_box[ 'title' ]; ?></label>
<input type="text" name="<?php echo $meta_box[ 'name' ]; ?>" value="<?php echo (isset($data[ $meta_box[ 'name' ] ]) ? htmlspecialchars($data[ $meta_box[ 'name' ] ]) : ''); ?>" />
<p><?php echo $meta_box[ 'description' ]; ?></p>
</div>
<?php } ?>
</div>
<?php
}
function wpb_save_meta_box($post_id) {
global $post, $meta_boxes, $key;
foreach($meta_boxes as $meta_box) {
if (isset($_POST[ $meta_box[ 'name' ] ])) {
$data[ $meta_box[ 'name' ] ] = $_POST[ $meta_box[ 'name' ] ];
}
}
if (!isset($_POST[ $key . '_wpnonce' ]))
return $post_id;
if (!wp_verify_nonce($_POST[ $key . '_wpnonce' ], plugin_basename(__FILE__)))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
update_post_meta($post_id, $key, $data);
}
add_action('admin_menu', 'wpb_create_meta_box');
add_action('save_post', 'wpb_save_meta_box');
function wpb_display_testimonials() {
$return_string .= "<div id=\"testimonials\">";
$args = array('post_type' => 'testimonial', 'posts_per_page' => 100, 'orderby' => 'menu_order', 'order' => 'ASC');
$loop = new WP_Query($args);
if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();
$data = get_post_meta($loop->post->ID, 'testimonial', true);
static $count = 0;
if ($count == "1") {
$pn_data = $data[ 'person-name' ];
$p_data = $data[ 'position' ];
$l_data = $data[ 'link' ];
$c_data = $data[ 'company' ];
$con_the = get_the_content($more_link_text, $stripteaser);
$return_string .= '<div class="slide" style="display: none">
<div class="client-contact-info">'; $return_string .= $pn_data; $return_string .=', '; $return_string .= $p_data; $return_string .=', <a href="'; $return_string .= $l_data; $return_string .='" title="'; $return_string .= $c_data ; $return_string .= '">'; $return_string .= $c_data ; $return_string .='</a></div>';
$return_string .= '<div class="clear"></div>
<div class="testimonial-quote">'; $return_string .= $con_the; $return_string .='</div>
</div>';
}
else {
$pn_data = $data[ 'person-name' ];
$p_data = $data[ 'position' ];
$l_data = $data[ 'link' ];
$c_data = $data[ 'company' ];
$con_the = get_the_content($more_link_text, $stripteaser);
$return_string .= '<div class="slide" >
<div class="client-contact-info">';
$return_string .= $pn_data;
$return_string .=', ';
$return_string .= $p_data;
$return_string .=', <a href="';
$return_string .= $l_data;
$return_string .='" title="';
$return_string .= $c_data ; $return_string .= '">';
$return_string .= $c_data ; $return_string .='</a></div>';
$return_string .= '<div class="clear"></div><div class="testimonial-quote">';
$return_string .= $con_the;
$return_string .='</div></div>';
$count++;
}
endwhile;
endif;
$return_string .='</div>';
return $return_string;
}
function register_shortcodes(){
add_shortcode('testme', 'wpb_display_testimonials');
}
add_action('init', 'register_shortcodes');
?>
감사합니다. 코드를 출력했지만 여전히 2 코드 문제가 있습니다. $ con_the = the_content(); 모든 내용 앞에 표시되며
에 표시되어야하며 jquery가 사라져서 작동하지 않는 것으로 나타납니다. –오른쪽, http://codex.wordpress.org/Function_Reference/the_content가 작동하지 않습니다. 단축 코드 생성 기능에서 http://codex.wordpress.org/Function_Reference/get_the_content ...를 사용해야합니다. jquery 코드'$ return_string'에 넣을 필요가 있습니다 – artlung
감사합니다. 나는 이것을 사용했고 작동합니다. 지금 당장 가지고있는 문제는 카운트가 작동하지 않는 것입니다. –