- This topic has 19 replies, 4 voices, and was last updated 1 year, 4 months ago by
Fernando.
-
AuthorPosts
-
July 11, 2022 at 10:01 am #2279712
Adarsha
Hey.
I was using “wpshow posts” all over my website. But now since latest update have changed every page to use query loop and its working great.
Only place I am stuck is one where I show only titles on sidebar.I will share all links in private info for you guys to check.
Current issue:
Now each title is taken as H2 or any other based on what i choose for title. While using wpshow posts each title was shown as “p. Have attached a page where Wpshowposts is being used so you guys can have a look.
Now since it takes each as H2 or any other I choose, it is inheriting all paddings and other stuff from H2/other thus making the titles bold, large spaces above and below. Further, I also don’t want to confuse google by showing all these titles as H2’s and stuff.
What is the possible solution for this?
July 11, 2022 at 10:24 am #2279733Ying
StaffCustomer SupportHi Adarsha,
As you are already using GenerateBlocks, I would recommend using GenerateBlocks’s query loop block instead of the WP query loop block.’
In that case, you will be able to choose
p
ordiv
as the titles, and it will give you much more control over every aspect.For more info about GB query loop block: https://docs.generateblocks.com/article/query-loop-overview/
July 18, 2022 at 10:07 am #2286511Adarsha
Yes that worked. Only issue is there is no option for “Open in new tab”.
Now if anyone clicks on related post built with this, it leaves the current page.The query block title block from wordpress had that option. How can I make sure it opens in new tab?
July 18, 2022 at 5:34 pm #2286781Fernando Customer Support
Hi Adarsha,
For now, you’ll need a filter to make them open in a new tab.
First, you’ll need to add
open-new-tab
to the class list of the Grid Block. It’s in the advanced section of the block’s settings.Then, you’ll need to add a PHP snippet like this:
function db_rerender_url_new_tab( $block_content, $block ) { if(!is_admin()){ if ( ! empty( $block['attrs']['className'] ) && 'open-new-tab' === $block['attrs']['className'] ) { $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 reference: https://docs.generatepress.com/article/adding-php/#code-snippets
Hope this helps!
July 19, 2022 at 12:01 am #2286958Adarsha
You mean for the query loop block?
July 19, 2022 at 12:06 am #2286967Fernando Customer Support
Good question. For the Grid Block within the Query Loop Block.
July 19, 2022 at 7:56 am #2287505Adarsha
This worked for my sidebar. But it did not work for my related posts bar at the bottom of the page.
Both have query loop from GB.The related posts block at the bottom also has another CSS class which was provided by you guys (To hide the post from same page).
So 2 classes are there. WordPress suggested to add new css with a space between old one. So I have added like thismy-class-name open-new-tab
Any idea why it may not be working?
Attached link to one of the post at the sensitive section.July 19, 2022 at 8:14 am #2287537David
StaffCustomer SupportHi there,
i do not see the
open-new-tab
class on that grid in the post you linked to.
Can you double check that ?July 19, 2022 at 9:54 am #2287629Adarsha
Have attached a screenshot in sensitive section.
July 19, 2022 at 10:29 am #2287661Ying
StaffCustomer SupportCan you try removing the
my-class-name
class?Does the
my-class-name
class trigger some JavaScript code?July 19, 2022 at 10:32 am #2287664Adarsha
https://generatepress.com/forums/topic/query-loop-2/
Please check this for why I added myclass
It hides the post from the page.July 19, 2022 at 11:52 am #2287728Ying
StaffCustomer SupportI see, but it should not conflict.
Anyway, you can remove the open-new-tab CSS from the Grid block, add it to the
image
block (featured image) and theheadline
block (title).July 19, 2022 at 7:33 pm #2287986Adarsha
That worked. Thank you 🙂
It would be great if you guys can add this and also not showing same post as the page as default options for query loop. Atleast provide in settings.. Especially the open in new tab.
July 20, 2022 at 9:41 am #2288735Ying
StaffCustomer SupportWe have the exclude current post option available for GB pro, unfortunately, free GB users will have to use PHP code.
But I agree the open in new window option should be available 🙂
We’ll see what we can do!
July 21, 2022 at 12:06 am #2289174Adarsha
I have GB pro.. How can I enable it without having to use PHP code?
-
AuthorPosts
- You must be logged in to reply to this topic.