- This topic has 3 replies, 2 voices, and was last updated 5 years, 3 months ago by
Tom.
-
AuthorPosts
-
January 30, 2017 at 3:35 pm #271991
Lyle
Not really a support question, just a way to enhance GP and WPSP π
The set up:
– use a page builder to spiff up a page that will be the “Blog” page, that is, a listing of the blogs, using WPSP shortcode to display them.
– this works fine and dandy π
– however, when a user selects one of those posts to read and then clicks the “Category” link in the single post meta, they are taken to the default archive.php page, which of course does not look as “spiffy” πThe “Fix” (well, for a single category anyway, and the reason for this query)
– copy the GP archive.php file to the GP child theme and then edit as such:
– remove this:<?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?>
… and replace it with this:
<?php echo do_shortcode( '[wp_show_posts id=60]' ); ?>
Works great with a single category. But when is more than one, it would be nice to have a “conditional” in there, such as this pseudo code:
if generate_archive_title = category-one, then do this shortcode
else
if generate_archive_title = category-two, then do that shortcode
… etc.I only know enough PHP to get me into trouble so if you have a minute to suggest something, it will be greatly appreciated π
http://snifflevalve.com
Tutorials and tips for GeneratePress, WP Show Posts, WordPress and ElementorGeneratePress 1.3.43GP Premium 1.2.94January 30, 2017 at 4:24 pm #272005Tom
Lead DeveloperLead DeveloperThat would definitely work! You can actually append the category slug to the file so that file will only apply to that specific category: https://developer.wordpress.org/themes/basics/template-hierarchy/#category
Also, no need to use the shortcode in the file, you can use the function provided while adding your list π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJanuary 30, 2017 at 4:50 pm #272007Lyle
Thats perfect Tom! π THANKS!
And for goodness sakes, I forgot all about the function being there in the WPSP list … I only “see” the shortcode π
I detect a tutorial video coming soon π
Cheers!
Lylehttp://snifflevalve.com
Tutorials and tips for GeneratePress, WP Show Posts, WordPress and ElementorJanuary 30, 2017 at 7:31 pm #272046Tom
Lead DeveloperLead DeveloperAwesome π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.