Categories

Featured templates

WordPress Cherry 3.x. How to make read more links of “post_grid” shortcode open in new tab

Stacy Martin April 6, 2015
Rating: 5.0/5. From 1 vote.
Please wait...

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:

  1. Open the wp-content/themes/themeXXXXX/includes directory and check if there’s already shortcodes/posts-grid.php file on server.

  2. 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.

  3. 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');
  4. Paste the code at the bottom of custom-function.php file before the closing ?> tag. Save changes in the file.

  5. 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>
  6. 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>
  7. 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>
  8. 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>
  9. 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

Top Wordpress Themes
This entry was posted in WordPress Tutorials and tagged more, post_grid, read, shortcode, tab, WordPress. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket