简体   繁体   English

Wordpress - 它有效,但我不知道为什么

[英]Wordpress - it works, but I don't know why

I'm writing a custom theme from scratch.我正在从头开始编写自定义主题。 As a menu, I use the jquery accordion control;作为菜单,我使用 jquery 手风琴控制器; each accordion item content is loaded using jquery.load(), as it follows:使用 jquery.load() 加载每个手风琴项内容,如下所示:

function accordion_show(divID, cat){
        $("#" + divID).addClass("aLoaderShow");
        $("#" + divID).load("<?php bloginfo('url') ?>/wp-content/themes/peng2/menu-content.php?q=" + cat);
        $("#" + divID).show();
        $("#" + divID).removeClass("aLoaderShow");
    }

I have also enabled mod_rewrite to get pretty posts permalinks.我还启用了 mod_rewrite 以获得漂亮的帖子永久链接。

I can't understand why the script works only if I leave two blank lines at the top of menu-content.php.我不明白为什么脚本只有在 menu-content.php 的顶部留下两个空白行时才有效。

I mean:我是说:

 <?php 
       $category = $_GET["q"];
       ...

it doesn't work.它不起作用。 But:但:

(blank line)
(blank line) 
<?php 
       $category = $_GET["q"];
       ...

it works?有用? It's a kind of magic?这是一种魔法?

Without knowing what you mean by "it works", it's impossible to give a full answer.如果不知道“它有效”是什么意思,就不可能给出完整的答案。

However, if I were to take a guess, I would say that the reason why you think it works with carriage returns is because the two carriage returns at the top of your file now means that the AJAX call receives data instead of nothing at all, which could be the original reason why it was not working.但是,如果我猜测一下,我会说您认为它与回车一起使用的原因是因为文件顶部的两个回车现在意味着 AJAX 调用接收数据而不是什么都没有,这可能是它不起作用的最初原因。

This suggests something is wrong in your PHP script ie it's not echoing out the value it's supposed to.这表明您的 PHP 脚本中有问题,即它没有回显它应该的值。 However, without being able to see what the rest of your PHP script does, I can't tell for certain.但是,由于无法查看 PHP 脚本的 rest 的作用,我无法确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM