是否有支持调用您创建的自定义函数的插件?
喜欢
第A页--我想调用函数x
$(document).ready(function(){
call_function_x()
});
第B页--我想调用函数y$(document).ready(function(){
call_function_y()
});
我不想在主输入中写入调用,因为其他人正在编辑,可能会由于错误执行而将其删除。。。这是我目前的解决方案,但在我看来不是最优的:)
footer.php:
<?php
/* Always have wp_footer() just before the closing </body>
* tag of your theme, or you will break many plugins, which
* generally use this hook to reference JavaScript files.
*/
wp_footer();
$js = get_post_meta($post->ID, \'javascript\', true);
if ( $js != "" ) {
?>
<script type="text/javascript">
$(document).ready(function(){
<?php echo $js; ?>
});
<?php } ?>
然后,我在页面上添加了自定义字段“javascript”,其自定义函数如下所示。function_x(some_variable); function_y(some_var); function_foo(bar);