Tag: wordpress

JQuery.js WordPress冲突

我有一个WordPress网站,它使用jQuery Mega Menu插件和theme-my-login两个调用: 在我的头部分: <?php /* Always have wp_head() just before the closing * tag of your theme, or you will break many plugins, which * generally use this hook to add elements to such * as styles, scripts, and meta tags. */ wp_head(); ?> 我必须包括: 这导致与WordPress jquery.js冲突 任何人都可以帮我解决这个问题吗? 或者让我知道为什么会发生这种冲突。 我从这场冲突中得到的错误是: Uncaught TypeError: undefined is […]

如何在wordpress中发送ajax请求而不显示零

我试图将ajax请求发送到wordpress中的另一个php页面。 但每次它返回零与其他结果。我需要删除零。 我试过die(); 删除零。 但在调用此function后,整个屏幕变为空白。 我的代码如下, jQuery的, function key_press(){ jQuery.ajax({ url : ‘admin-ajax.php’, type : ‘POST’, data : jQuery(‘[name=”ans_name”]’).serialize() }).done(function(result) { // ta da //alert(“success”); jQuery(“#widget_poll_id”).html(result); }); } PHP, add_action( ‘wp_ajax_nopriv_’.$_POST[‘ans_name’], ‘my_ajax’ ); add_action( ‘wp_ajax_’.$_POST[‘ans_name’], ‘my_ajax’ ); function my_ajax() { echo $_POST[‘ans_name’]; die(); } 我怎么能摆脱这种情况?

Jquery加载工作,直到我重新启动Wampserver,然后不再

我试着通过Jquery .load()在Wordpress上加载一些内容。 有时候,当我的代码没问题时,它在第二天就不再工作…… 我正试图缩小原因。 首先我认为这是一个语法问题或单/双引号混淆,但由于它工作一次,没有理由语法或错误。 我考虑过错误的缓存设置,但shift + F5不会破坏我的工作代码。 现在,我尝试使用完美的代码关闭并重新启动WAMPserver。 而Bingo,当我重新启动服务器时,我的装载function无法工作(从1分钟开始……)! 编辑:我刚刚用我正在使用的代码替换了代码(下面) $(document).ready(function(){ $.ajaxSetup({cache:false}); $(“#portfolio-list li:not(#DrawerContainer)”).click(function(){ var post_link = $(this) //.parentsUntil(“.ProjectWrap”) //.parent() .find(‘.mosaic-backdrop’) .attr(“href”); console.debug(post_link); //to get post_link info in the console $(‘#DrawerContainer’).remove(); // remove existing, if any $(”).attr(‘id’, ‘DrawerContainer’).css({display: ‘none’}).data(‘citem’, this).html(“loading…”).load(post_link + ” #container > * “).insertAfter(LastInRow).slideDown(500); return false; }); }); 当函数不起作用时,我尝试删除部分.load(post_link + ” #container […]

选择“孙子”

我有一个充满挑战的问题! 让我们看看三种可能的情况 情景1 场景2   场景3   text 或其他项目的数量将是未定义的。 我怎么能只选择第一个img进行“display:none;”? 我的猜测是我必须把.entry-content作为父母,但是如果我做一个img:first-child,它会将 作为父级,并且如果有更多的话,它将不显示所有图片。 这就是为什么应该像祖父一样:D如果我们必须使用其他语言而不是CSS,我当然是开放的。

防止恶意软件javascript执行

我正在使用wordpress网站,我发现了一个恶意软件脚本,每当我尝试保存页面并点击WYSIWYG中的文本面板时,恶意软件javascript标记会自动添加到页面中。 这是自动添加的脚本。 我试图通过以下代码删除src文件。 但它没有用,脚本在关闭body标签之前执行。 我尝试使用此脚本,但恶意软件脚本在加载所有javascript后加载。 这是我的代码。 $(“script[src=’http://cracks4free.info/5/adds.js’]”).remove() 我需要删除此代码,或阻止此代码通过javasript,jquery,ajax执行任何东西..只是想摆脱这个。 谢谢

当你使用Jquery按下按钮时,我试图让我的页面滚动得更慢?

我是JQuery的新手,我可以让页面转到顶部和底部,就像我想减慢运动速度一样。 那么如何减慢滚动速度呢? 这是我到目前为止: document.getElementById(‘sur2’).onclick = function () { document.getElementById(‘pt1′).style.display=’block’; document.getElementById(‘pt2′).style.display=’none’; window.scroll(0,0); } document.getElementById(‘sur1’).onclick = function () { document.getElementById(‘pt1′).style.display=’none’; document.getElementById(‘pt2′).style.display=’block’; window.scroll(0,5000); }

如何包含wp-blog-header.php更改文件位置?

我有这个javascript: $(‘.publish_post’).click (function(){ var info = ‘some info’; $.ajax({ type: “POST”, url: “../actions/addpost.php”, data: info, success: function(data){ console.log(data); } }); }) 我有一个名为addpost.php的文件,它位于WP的根安装文件夹中的actions文件夹中。 ‘closed’, ‘ping_status’ => ‘closed’ , ‘post_category’ => 1, ‘post_content’ => ‘some content’, ‘post_name’ => ‘some post’, ‘post_status’ => ‘publish’, ‘post_title’ => ‘some post’, ‘post_type’ => ‘post’ ); $the_post_id = wp_insert_post( $post, $wp_error ); […]

如何让scrollToFix插件限制停在我网站的页脚?

我在我的网站上使用scrollToFix脚本来修复广告,因为用户向下滚动页面以及当用户到达页脚时释放(以便广告不与页脚重叠)。 但是,下面的代码会导致广告停止在页面的三分之一和一半之间滚动,而不是在页脚处。 将其设置为滚动到容器的outerHeight减去页脚的高度,使其停止在该位置。 $(document).ready(function() { $(‘.right’).scrollToFixed({ marginTop: $(‘.float’).outerHeight() + 8, limit: $(‘footer’).offset().top }); }); 有没有关于如何更准确地停止它的想法?

jQuery和WordPress – 脚本不起作用

我试图将一些jquery实现为我正在创建的wp插件。 在我的主题的functions.php中,我有以下代码: function load_jquery() { // only use this method is we’re not in wp-admin if ( !is_admin() ) { // deregister the original version of jQuery wp_deregister_script(‘jquery’); wp_deregister_script(‘jquery-ui-slider’); wp_deregister_style(‘jquery-ui-style’); // discover the correct protocol to use $protocol=’http:’; if($_SERVER[‘HTTPS’]==’on’) { $protocol=’https:’; } // register the Google CDN version wp_register_script(‘jquery’, $protocol.’//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js’, false, ‘1.10.2’); wp_register_script(‘jquery-ui-slider’, $protocol.’//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js’, false, […]

Jquery脚本无法在WordPress中运行,尝试了多种排队方法

我搜索过类似的问题,但还没有找到答案。 在使用Genesis框架的Wordpress 开发站点上 ,我尝试使用以下jquery脚本: smoothscroll.js和Matt Verone的动态顶部(WP插件版本和手动)。 两者都不起作用。 我已经成功地在WP和非WP站点上使用了这两个。 我通过functions.php中的以下方法将smoothscroll.js和动态到顶级脚本(手动使用时),easing.js和jquery.ui.totop.min.js排队。 function tm_scripts() { wp_register_script( ‘easing’, get_stylesheet_directory_uri() . ‘/lib/js/easing.js’, array( ‘jquery’ ), null, true ); wp_register_script( ‘smoothscroll’, get_stylesheet_directory_uri() . ‘/lib/js/smoothscroll.js’, array( ‘jquery’ ), null, true ); wp_register_script( ‘jquery.ui.totop.min’, get_stylesheet_directory_uri() . ‘/lib/js/jquery.ui.totop.min.js’, array( ‘jquery’ ), null, true ); wp_register_script( ‘main’, get_stylesheet_directory_uri() . ‘/lib/js/main.js’, array( ‘jquery’ ), null, true […]