您好,我想知道如何在新选项卡或窗口中打开管理帖子/自定义帖子类型和页面上的“查看”链接。
我知道这可能是通过函数实现的。php文件的主题,并宁愿走这条路线,而不是使用插件。
如果您对此有任何帮助,我们将不胜感激。谢谢。:)
您好,我想知道如何在新选项卡或窗口中打开管理帖子/自定义帖子类型和页面上的“查看”链接。
我知道这可能是通过函数实现的。php文件的主题,并宁愿走这条路线,而不是使用插件。
如果您对此有任何帮助,我们将不胜感激。谢谢。:)
迟交的答复
WP core为这种情况提供了一个功能,这使得它更容易实现并经得起未来的考验:只需将它映射到每个项目上即可。
<?php
/* Plugin Name: (#32093) »kaiser« Open "action"-links in post type list screens in new windows/tabs */
function wpse32093_link_target_blank( $actions, $post )
{
return array_map( \'links_add_target\', $actions );
}
// Add to each post type
foreach ( array( \'post\', \'page\' ) as $post_type )
add_action( "{$post_type}_row_actions", \'wpse32093_link_target_blank\', 20, 2 );
插件经过测试,可以无缝工作。您可以在foreach循环内的数组中调整要使其处于活动状态的post类型。<?php
/*
Plugin Name: [Editor] Popup View
Author URI: http://www.earnestodev.com/
Description: Opens View link in new windows for in posts and pages manager.
Author: EarnestoDev
Version: 5.U.B
Author URI: http://www.earnestodev.com/
*/
// ----------------------------------------------------------------- //
function popup_view_row_action($actions, $post){
// Walk array with value references for easy changing
if(is_array($actions)) foreach($actions as $key => &$value){
// For the right row_action
if(($key === \'view\') and is_string($value)){
// Add the target="_blank" in the A tag\'s attributes
$value = preg_replace(\'~<a[\\s]+~i\', \'<a target="_blank" \', $value);
}
}
return $actions;
}
// ----------------------------------------------------------------- //
// Hooks both hierarchical and non-hierarchical
add_action(\'page_row_actions\', \'popup_view_row_action\', 11, 2);
add_action(\'post_row_actions\', \'popup_view_row_action\', 11, 2);
// ----------------------------------------------------------------- //
?>
在此处放入文件/wp-contents/mu-plugins/popup-view-action.php 或者在这里/wp-contents/plugins/pupup-view-action.php 然后激活。当做
我目前正在使用get\\u posts()作为我正在处理的主题的一小部分。然而,我遇到了一个小问题。If I want to show all posts for a category, I set the \'numberposts\' argument to \'-1\'. However the issue is that when I do this, the offset no longer works. 我确实看到我告诉函数返回所有帖子,但我希望它不会返回所有帖子。因此,我确实看到了逻辑上的两