如何删除?p=来自WordPress短链接?
我删除了?p=从wp\\u get\\u shortlink获取链接,它没有?p=成功,但该链接在添加之前不起作用的问题?p=那么,如何使链接在没有添加的情况下工作?p=。
如何删除?p=来自WordPress短链接?
我删除了?p=从wp\\u get\\u shortlink获取链接,它没有?p=成功,但该链接在添加之前不起作用的问题?p=那么,如何使链接在没有添加的情况下工作?p=。
我不知道你是怎么删除的?p=
从链接,但您可以使用get_shortlink
筛选以覆盖短链接。有关更多详细信息,请参阅下面的文章。
http://www.wpbeginner.com/wp-themes/how-to-display-wordpress-shortlinks-in-your-theme/
参考get_shortlink
过滤器:https://developer.wordpress.org/reference/hooks/get_shortlink/您能否分享有关如何删除的更多详细信息?p=从链接?
@你可以添加yogu 在permalink中获取所需的结构。
site-url.com/22 (without ?p=)
对于特定帖子,您可以添加以下函数并为其添加特定条件:
add_filter( \'post_link\', \'custom_permalink\', 10, 3 );
function custom_permalink( $permalink, $post, $leavename ) {
// For shortlink condition
if ( \'Shortlink Condition here\' ) {
$permalink = trailingslashit( home_url(\'/\'. $post->ID .\'/\' ) );
}
return $permalink;
}
add_action(\'generate_rewrite_rules\', \'custom_rewrite_rules\');
function custom_rewrite_rules( $wp_rewrite ) {
// This rule will will match the post id in %post_id% struture
$new_rules[\'^([^/]*)-([0-9]+)/?\'] = \'index.php?p=$matches[2]\';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
return $wp_rewrite;
}
Wordpress重定向时不带参数:?p、 不管是页面还是帖子。。。
例如:站点。com/922(帖子或页面ID…),这应该重定向。
如果您想更改站点头部的链接1:
add_filter(\'pre_get_shortlink\', function () {
return home_url(\'/\') . get_the_ID();
}, 10, 3);
在wordpress文档中:https://developer.wordpress.org/reference/hooks/pre_get_shortlink/我试图在标题中加载一个滑块,但只在主页上加载。如果有帮助的话,我正在使用Ultralight模板。我正在尝试(在template functions.php中)执行以下操作:<?php if ( is_page( \'home\' ) ) : ?> dynamic_sidebar( \'Homepage Widget\' ); <?php endif; ?> 但这行不通。现在,通过快速的google,我似乎需要将请