Javascript wordpress的动态行短代码
我正在尝试添加一个短代码,以便在wordpress内容中设置网格。我的主题基于foundation5,因此我创建了一个名为“Shortcodes.php”的新文件,并将其加载到functions.php中。我将以下代码插入到短代码文件中Javascript wordpress的动态行短代码,javascript,php,wordpress,shortcode,zurb-foundation-5,Javascript,Php,Wordpress,Shortcode,Zurb Foundation 5,我正在尝试添加一个短代码,以便在wordpress内容中设置网格。我的主题基于foundation5,因此我创建了一个名为“Shortcodes.php”的新文件,并将其加载到functions.php中。我将以下代码插入到短代码文件中 <?php function spalten_zeilen_function($atts, $content = null) { extract(shortcode_atts(array( 'width' => '',
<?php
function spalten_zeilen_function($atts, $content = null) {
extract(shortcode_atts(array(
'width' => '',
'position' => '',
'vertical' => '',
), $atts));
if ( $position == 'first' ) {
$return_string = '<div class="row '.$vertical.'">';
}
$return_string = '<div class="small-'.$width.' columns '.$position.';">';
$return_string = do_shortcode($content);
$return_string .= '</div>';
if ( $position == 'end' ) {
$return_string = '</div>';
}
wp_reset_query();
return $return_string;
}
function register_shortcodes(){
add_shortcode('grid_shortcode', 'spalten_zeilen_function');
}
add_action( 'init', 'register_shortcodes');
add_filter('widget_text', 'do_shortcode'); // Shortcodes auch in Widgets ausführen
add_filter( 'comment_text', 'do_shortcode' ); // Shortcodes auch in den Kommentaren ausführen
add_filter( 'the_excerpt', 'do_shortcode'); // Shortcodes auch in den Excerpts ausführen
?>
所以我会期待类似的事情
<div class="row"><div class="small-6 columns first">
Fügen Sie hier den den gewünschten Inhalt Ihrer neuen Spalte ein.</div>
所以我会期待像这样的事情
<div class="small-6 columns end">Fügen Sie hier den den gewünschten Inhalt Ihrer neuen Spalte ein.</div></div>
Fügen你是新来的。
但它只是杀死了我的模板。有什么想法或建议吗
谢谢你们 实际上,它只是缺少点而已
<?php
function spalten_zeilen_function($atts, $content = null) {
extract(shortcode_atts(array(
'position' => '',
'width' => '',
'vertical' => '',
), $atts));
$return_string = '';
if ( $position == 'first' ) :
$return_string .= '<div class="small-12 columns"><div class="row '.$vertical.'">';
endif;
$return_string .= '<div class="small-'.$width.' columns '.$position.';">';
$return_string .= do_shortcode($content);
$return_string .= '</div>';
if ( $position == 'end' ) :
$return_string .= '</div></div>';
endif;
wp_reset_query();
return $return_string;
}
function register_shortcodes(){
add_shortcode('grid_shortcode', 'spalten_zeilen_function');
}
add_action( 'init', 'register_shortcodes');
add_filter('widget_text', 'do_shortcode'); // Shortcodes auch in Widgets ausführen
add_filter( 'comment_text', 'do_shortcode' ); // Shortcodes auch in den Kommentaren ausführen
add_filter( 'the_excerpt', 'do_shortcode'); // Shortcodes auch in den Excerpts ausführen
应该添加什么?\u filter(“…”,“do_shortcode”)do?widget\u text=在小部件注释中使用时运行短代码\u text=在注释中使用时运行短代码\u extract=在摘录中使用时运行短代码
<div class="small-6 columns end">Fügen Sie hier den den gewünschten Inhalt Ihrer neuen Spalte ein.</div></div>
<?php
function spalten_zeilen_function($atts, $content = null) {
extract(shortcode_atts(array(
'position' => '',
'width' => '',
'vertical' => '',
), $atts));
$return_string = '';
if ( $position == 'first' ) :
$return_string .= '<div class="small-12 columns"><div class="row '.$vertical.'">';
endif;
$return_string .= '<div class="small-'.$width.' columns '.$position.';">';
$return_string .= do_shortcode($content);
$return_string .= '</div>';
if ( $position == 'end' ) :
$return_string .= '</div></div>';
endif;
wp_reset_query();
return $return_string;
}
function register_shortcodes(){
add_shortcode('grid_shortcode', 'spalten_zeilen_function');
}
add_action( 'init', 'register_shortcodes');
add_filter('widget_text', 'do_shortcode'); // Shortcodes auch in Widgets ausführen
add_filter( 'comment_text', 'do_shortcode' ); // Shortcodes auch in den Kommentaren ausführen
add_filter( 'the_excerpt', 'do_shortcode'); // Shortcodes auch in den Excerpts ausführen