Home › Forums › Support › Click the article link on page A to jump and then go to the new page B. How to s
- This topic has 22 replies, 3 voices, and was last updated 3 years, 4 months ago by
Fernando.
-
AuthorPosts
-
December 23, 2022 at 5:55 am #2471492
RYAN
Click the article link on page A to jump and then go to the new page B. How do I set it?
I want articles on the home page and articles on custom pages to jump like this
December 23, 2022 at 12:14 pm #2471854Leo
StaffCustomer SupportHi there,
Click the article link on page A to jump and then go to the new page B.
Sorry but I don’t understand what you are trying to achieve here – do you happen to have an example to show?
December 23, 2022 at 6:49 pm #2472022RYAN
For example, the following
December 25, 2022 at 8:48 pm #2473269RYAN
Anyone here?
December 25, 2022 at 9:18 pm #2473286Fernando Customer Support
Hi Ryan,
Sorry, your previous response may have slipped through our system.
To clarify, are you referring to a link opening in a new tab?
December 25, 2022 at 9:21 pm #2473287RYAN
yes
I find Fernando knows me best
I like you very much hahahaDecember 25, 2022 at 11:08 pm #2473327Fernando Customer Support
You’re using the default template for the Blog page. For other archive pages, you seem to be using a Block Element – Content Template.
It would be easier, and less code would be needed if both the Blog and Archive pages are built in the same way. Would you be open to using the same Content Template you have in your Blog as well?
December 25, 2022 at 11:40 pm #2473346RYAN
Yes. Then how can I set it
December 26, 2022 at 12:01 am #2473356Fernando Customer Support
Add
cu-new-tabto the class list of the Headline or Image Block link.Adding Custom Classes: https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/
Then, add this snippet:
function db_rerender_url_new_tab( $block_content, $block ) { if(!is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'cu-new-tab' ) !== false ) { $my_search='href="'; $my_replace='target="_blank" href="'; $new_content = str_replace($my_search, $my_replace, $block_content); return $new_content; } return $block_content; } add_filter( 'render_block', 'db_rerender_url_new_tab', 10, 2 );Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
December 26, 2022 at 12:24 am #2473375RYAN
Other pages are OK,
The home page is still not good. What else should be set for this page
December 26, 2022 at 12:29 am #2473378Fernando Customer Support
I see. If it’s a menu item, you need to set it in the Menu itself. It’s shown here: https://docs.generatepress.com/article/using-the-wordpress-menu-builder/#opening-in-a-new-window-tab
Enable “Open in new tab/window” for the menu items as shown in the link above.
December 26, 2022 at 12:41 am #2473384RYAN
I added it, but it still doesn’t work. Clicking the article link will not open a new tab page
December 26, 2022 at 12:48 am #2473388Fernando Customer Support
The
cu-new-tabis for GB Blocks in your Content Template.For menu items, you need to follow what I said here: https://generatepress.com/forums/topic/click-the-article-link-on-page-a-to-jump-and-then-go-to-the-new-page-b-how-to-s/#post-2473378
There should be a toggle there to set a menu item to Open in a new tab.
December 26, 2022 at 1:13 am #2473410RYAN
Yes, I checked it, but it is not the page to jump to by clicking the article link, but the function to jump to a new page when clicking the home page. You can check my icon or the home page of my website
December 26, 2022 at 1:35 am #2473430Fernando Customer Support
Can you reiterate what you want to happen? I’m not sure I’m still understanding what you want to happen. 🙂
If you can provide an example, that would be great.
-
AuthorPosts
- You must be logged in to reply to this topic.