- This topic has 7 replies, 3 voices, and was last updated 1 year, 11 months ago by David.
-
AuthorPosts
-
April 28, 2022 at 12:28 pm #2203261eadcock
My client would like to have the option to add a secondary title to their blog posts and have it visible under the post title on the summary pages. I was able to add it to the single post page via custom fields and a custom field element hook, but I’m unable to find how to add it to the summary pages. I’m currently using a query loop to bring in post summaries. I was trying the route of a block element with dynamic content, but for some reason dynamic content is not available on header or button blocks. Does it need to be activated somewhere?
Your help is appreciated!April 28, 2022 at 1:22 pm #2203287YingStaffCustomer SupportHi there,
but for some reason dynamic content is not available on header or button blocks.
I’m not sure I fully understand this sentence, can you explain a bit more?
If you are trying to add a block element with dynamic content to a query loop block in a static page, it’s not going to work.
You can add block element to the default blog/archive page.
April 29, 2022 at 6:21 am #2203787eadcockThanks Ying, The dynamic content I was referencing is in this article: https://docs.generatepress.com/article/dynamic-data/. So is there any way to add dynamic content to the query loop? The reason I’m not using the default blog/archive page is that I used the post element for job postings and team in addition to blog posts so the default blog/archive page pulls all that content. Is there a way to filter the default blog/archive page? That would be a solution as well.
April 29, 2022 at 6:33 am #2203799DavidStaffCustomer SupportHi there,
the GP Dynamic Data only works inside the Block Element.
And to the best of my knowledge there is no open hooks for adding content to the Core Query Loop block. I am not sure if it even supports adding a Shortcode for other data.As a note we will be soon releasing GenerateBlocks 1.5 which will have dynamic data and its own Query Loop that will support some custom post meta.
Using the theme templates – whats the current issue with blog/archive page ? is there a post type or category that you need to exclude ? Let me know.
April 29, 2022 at 6:36 am #2203805eadcockThank you David,
And you’re correct. I’m using the post function for multiple categories, so if there’s a way to filter the default blog/archive – and/or create multiple archives for different categories or post types – that would work.April 29, 2022 at 6:44 am #2203811DavidStaffCustomer SupportSo you can add the following PHP Snippet to exclude a Category from the Blog:
function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', array( -22 ) ); } } add_action( 'pre_get_posts', 'exclude_category' );
the
-22
is the ID of the Category you want to exclude ( if you edit a Category term, and look at the browser URL field it will show the ID=XX ).As its an array you exclude multiple categories if required eg
$query->set( 'cat', array( -22, -33, -59 ) );
Adding PHP: https://docs.generatepress.com/article/adding-php/
In addition each category will have its own URL to display its archive page eg.:
https://your-site.com/category/your-category-slug
April 29, 2022 at 9:59 am #2204220eadcockThank you David!
That worked famouslyApril 30, 2022 at 2:36 am #2204625DavidStaffCustomer SupportGlad to hear that
-
AuthorPosts
- You must be logged in to reply to this topic.