我正在使用wordpress创建一个求职网站。我想创建一个自定义.htaccess规则,以便当用户在表单中搜索作业时,第一部分将作为文件夹结构,其余部分将添加为查询参数。
仅当我们在url中查询参数?find = any-value时才会这样 休息页面就像它一样 http://example.com/contact/
我想要: -
http://example.com/?find=any-value&job_location=Austin,TX&findjobs=Search
成为: -
http://example.com/any-value?job_location=Austin,TX&findjobs=Search
我的永久链接设置如下: -
http://example.com/sample-post/
QA .htaccess代码
# Special redirects
RewriteCond %{QUERY_STRING} ^find=([^/]*)$
RewriteRule ^/?$ /%1\/? [R=301,L]
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
答案 0 :(得分:0)
您应该在b = pd.Series(np.concatenate(df['A'])).str.split(expand=True).stack().str.isupper().sum()
print (b)
3
挂钩中使用wp_redirect
功能。
可以添加到template_redirect
示例:
functions.php
链接:
答案 1 :(得分:0)
+1给你Maxwell非常感谢以下是其他人的工作代码;)
add_action('parse_request', 'vm_parse_request');
function vm_parse_request(&$wp) {
if (isset($_GET['find'])) {
// get site url
$url = get_site_url() . '/' . $_GET['find'];
// clone GET arguments
$query = $_GET;
// remove the find argument
unset($query['find']);
// add all get arguments to the new url
$url = add_query_arg($query, $url);
// redirect to the generated url
wp_redirect($url);
exit();
}
if (isset($_GET['findjobs'])) {
// setup hooks and filters to generate virtual movie page
add_action('template_redirect', 'vm_template_redir');
//add_filter('the_posts', 'vm_createdummypost');
//add_filter('the_content', 'j2c_job_display');
// remove_filter('the_content', 'wpautop');
}
}
function vm_template_redir() {
// Reset currrently set 404 flag as this is a plugin-generated page
global $wp_query, $post;
$wp_query->is_404 = false;
header("HTTP/1.1 200 OK");
$urlslug = explode("/", $_SERVER['REQUEST_URI']);
$urlslug = explode("?", $urlslug[1]);
$post = get_post(165, OBJECT);
//$post->content = "hello testhere";
setup_postdata($post);
add_action('wp_enqueue_scripts', 'j2c_enqueue', 9999);
$_GET['find'] = str_replace("/", "", $urlslug[0]);
// add_filter('the_content', 'j2c_job_display');
wp_reset_postdata();
$template_path = plugin_dir_path(__FILE__) . 'template/page.php';
include( $template_path); // child
exit;
}