Php 在wordpress插件中集成选项
为了添加一个选项页面,我遵循了文档 但是我不能集成我的插件的任何自定义选项。 假设在我的插件中有一个短代码,在一个部分中有一个可以通过自定义编码更改的背景。e、 gPhp 在wordpress插件中集成选项,php,wordpress,Php,Wordpress,为了添加一个选项页面,我遵循了文档 但是我不能集成我的插件的任何自定义选项。 假设在我的插件中有一个短代码,在一个部分中有一个可以通过自定义编码更改的背景。e、 g extract( shortcode_atts( array( 'category' => '', 'background'=> '#333', 'border-width' => '10px' ), $atts, 'photo_gallery' ) ); $q = new WP_Que
extract( shortcode_atts( array(
'category' => '',
'background'=> '#333',
'border-width' => '10px'
), $atts, 'photo_gallery' ) );
$q = new WP_Query(
array('photo_gallery_cat' => $category, 'posts_per_page' => -1, 'post_type' => 'photo-items')
);
$list = '<section border="$border-width" style="background-color:'.$background.'"><ul id="gallery"><li style="background-color: '.$background.'" id="fullPreview"></li>';
while($q->have_posts()) : $q->the_post();
如何从选项页使用此真/假选项?您必须使用
get\u option('new\u option\u name')拉取选项。
。在您的短代码中:
// #aaa is the default, if nothing is saved yet
$background = get_option( 'new_option_name', '#aaa' );
对于jQuery库:
$scroll = get_option( 'some_other_option', false );
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#gallery').least({
'scrollToGallery': <?php echo $scroll; ?>
});
});
</script>
$scroll=get\u选项('some\u other\u option',false);
jQuery(文档).ready(函数(){
jQuery(“#gallery”)。至少({
“滚动列表”:
});
});
或者在脚本排队时使用。Brasofilo,谢谢您的回答。一个需要理解的小问题。背景选项将在哪里使用?我应该更换哪一行?或者别的什么事?虽然我是新来的,但在使用上面临困难。学习编程意味着大量的尝试和错误。我的例子包含在您提供的例子中$在短代码中使用它之前,先使用背景。您的选项页面正常吗?抱歉,aarif,您提供的信息不足以帮助您。你能阅读指南并更新你的问题吗?
$scroll = get_option( 'some_other_option', false );
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#gallery').least({
'scrollToGallery': <?php echo $scroll; ?>
});
});
</script>