如何在新标签页打开WordPress文章?Hoot Business主题无loop.php时的解决方法
Hey there! I get it—hunting for loop.php and coming up empty can be frustrating, but don’t worry, there are plenty of other solid ways to make your posts open in new tabs with the Hoot Business theme. Let’s break down the most reliable methods:
1. Check the Theme Customizer First (Easiest Option)
Many premium themes like Hoot Business build this setting right into the Customizer. Head to Appearance > Customize and dig around sections like:
- Layout Settings
- Blog/Archive Settings
- Post Display Options
Keep an eye out for a toggle or dropdown labeled something like "Open post links in new tab" or "Link target for post titles". If you spot it, just flip the switch and save your changes—you’re done!
2. Add a Code Snippet to functions.php
If the Customizer doesn’t have the option, a small code snippet in your theme’s functions.php (or a custom snippets plugin) will do the trick. This works site-wide for all post and page links.
Here’s the code you’ll need:
// Open posts and pages in new tabs with secure attributes function open_posts_in_new_tab($link) { return str_replace('<a href=', '<a target="_blank" rel="noopener noreferrer" href=', $link); } // Apply the filter to post and page permalinks add_filter('post_link', 'open_posts_in_new_tab'); add_filter('page_link', 'open_posts_in_new_tab');
Important note: Always use a child theme when modifying functions.php—this ensures your changes won’t get erased when the Hoot Business theme updates. If you don’t want to mess with child themes, use a plugin like Code Snippets to add the code safely.
3. Edit Specific Template Files (Targeted Changes)
If you only want post links in certain areas (like the homepage or archive pages) to open in new tabs, you can edit the relevant template files. Hoot Business likely uses files like index.php, archive.php, or content.php instead of loop.php to render post content.
- Go to Appearance > Theme File Editor (or use an FTP client to access your theme files).
- Start with
content.php—this is where most themes output post titles and links. - Find the line with the post title link, which will look something like:
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> - Modify it to include the target and security attributes:
<a href="<?php the_permalink(); ?>" target="_blank" rel="noopener noreferrer"><?php the_title(); ?></a> - Save your changes. Again, use a child theme for edits to avoid losing them on theme updates.
4. Use a Lightweight Plugin (No-Code Option)
If you’re not comfortable with code, a simple plugin can handle this. Look for well-maintained options like "Open Links in New Tab" or "WP External Links"—you can tweak their settings to apply to internal post links too. Just install, activate, and set the plugin to open internal post links in new tabs. Stick to lightweight plugins to avoid slowing down your site.
内容的提问来源于stack exchange,提问作者Alex Alojado

