English 中文(简体)
Wordpress URI hook“在寻找员额之前”
原标题:Wordpress URI hook "before post search"

I m trying to write a wordpress plugin that searches allows for the "third segment" of the URI to be a parameter.

因此,例如,我的基本联系结构如下:%/%post%

I ve got a category for "myplugin" and a post called "myitem" this would be accessible via: /myplugin/myitem

I need to be able to add a third parameter: /myplugin/myitem/the_item_identifier

在我旁边,我有某种逻辑可以处理这个案件,像这样的情况。

function myplugin_hook_before_uri_read(){
    $fields = explode( / ,$_SERVER["REQUEST_URI"]);
        if (count($fields) == 4 && $fields[1] == "myplugin" && $fields[2] == "myitem") {
            // fix things so we re redirected into the correct post.
    }
}

to be fair, I could probably manage the same effect by using the URI /myplugin/myitem/?the_item_identifier

So maybe it s not the end of the world. Though I d feel a lot cleaner if I could work without the ?

另外,如果能以更好的方式添加一 h,请就此发言。 我不与这种方法结婚,这只是我能够想实现的唯一途径。

EDIT in response to Chris question below,

in this case, the_item_identifier is the primary key from a third party XML document.

例如,如果是产品清单,我就有一个单一职位,即产品“显示模板”。

问题回答

你们计划用什么来“项目_识别者”? 在“压力”仪表板上已经形成了一种选择,使你能够使习俗永久化。 我经常使用:

百分比/%

http://codex.wordpress.org/Using_Permalinks”rel=“nofollow” WordPress Permalinks page for a list of options to use between the% % to make permalink structure.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签