- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
WordPress Cherry 3.x. How to make read more links of “post_grid” shortcode open in new tab
April 6, 2015
This tutorial shows how to edit posts_grid shortcode so that Read More links and titles of posts opened in new tab.
WordPress. How to make read more links of “post_grid” shortcode open in new tab
In order to change shortcode behavior, you will need to edit the shortcode source code in the child theme, i.e. in the wp-content/themes/themeXXXXX/includes directory on server:
-
Open the wp-content/themes/themeXXXXX/includes directory and check if there’s already shortcodes/posts-grid.php file on server.
-
In case the file is missing, open the custom-function.php file and check if there’s already posts_grid code in the file: look for the posts_grid with Ctrl/Cmd+F5 hotkeys.
-
In case the code is missing, open the posts-grid.php file located in the wp-content/plugins/cherry-plugin/includes/shortcodes directory on server and copy the code that starts with:
function posts_grid_shortcode( $atts, $content = null, $shortcodename = '' ) {
And ends with:
add_shortcode('posts_grid', 'posts_grid_shortcode');
-
Paste the code at the bottom of custom-function.php file before the closing ?> tag. Save changes in the file.
-
Find the posts title link in the source code:
<a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">'; $output .= get_the_title($post_id); $output .= '</a>
-
In order to open link in new tab, add target=”_blank” into the link code:
<a target="_blank" href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">'; $output .= get_the_title($post_id); $output .= '</a>
-
To modify the Read More button link, find the button link code which is the following:
<a href="'.get_permalink($post_id).'" class="btn btn-primary" title="'.get_the_title($post_id).'">'; $output .= $link_text; $output .= '</a>
-
Add the same target=”_blank” attribute to the link code:
<a target="_blank" href="'.get_permalink($post_id).'" class="btn btn-primary" title="'.get_the_title($post_id).'">'; $output .= $link_text; $output .= '</a>
-
Save changes in the custom-function.php file. Refresh the page with Ctrl/Cmd+F5 hotkeys to see changes on the site.
Feel free to check the detailed video tutorial below:
WordPress. How to make read more links of “post_grid” shortcode open in new tab