Для вывода определеного контента на движке вордпресс практикую подключение через плагин стилей скриптов.
Структура проста
1)my_plagin.php
2) css\
style/css
3)js\
script.js
my_plagin.php
Для нужной записи добавляем шорткод
[my_plagin][/my_plagin]
Структура проста
1)my_plagin.php
2) css\
style/css
3)js\
script.js
my_plagin.php
<?php
/*
Plugin Name: my
Plugin URI: http://my
Description: my
Version: 1.0.0
Author: саша
Author URI: http://my
*/
function my_shortcode($atts){
wp_enqueue_script( 'my-script',plugins_url('my/js/script.js' ), array('jquery'), NULL, true);
return"
<div>Text</div>
";
// if you add a css it will be added to the footer
//wp_enqueue_style( 'my-css', plugins_url( //'plugin_name/css/style.css' ) );
//the rest of shortcode functionality
}
add_shortcode( 'my_plagin', 'my_shortcode' );
?>
/*
Plugin Name: my
Plugin URI: http://my
Description: my
Version: 1.0.0
Author: саша
Author URI: http://my
*/
function my_shortcode($atts){
wp_enqueue_script( 'my-script',plugins_url('my/js/script.js' ), array('jquery'), NULL, true);
return"
<div>Text</div>
";
// if you add a css it will be added to the footer
//wp_enqueue_style( 'my-css', plugins_url( //'plugin_name/css/style.css' ) );
//the rest of shortcode functionality
}
add_shortcode( 'my_plagin', 'my_shortcode' );
?>
Для нужной записи добавляем шорткод
[my_plagin][/my_plagin]
Комментариев нет:
Отправить комментарий