- This topic has 7 replies, 3 voices, and was last updated 5 years, 4 months ago by Leo.
-
AuthorPosts
-
December 1, 2018 at 8:09 am #745499horst
hello everybody,
thanks again for this beautiful theme and its great support. (i recently prolonged my license until 2020)!
i have perhaps an easy to solve problem, but dont know which would be the best way to do it.on my homepage (i.e. the blogpage) i want to display one column of latest posts (and two sidebars), on the archive pages two columns (and one sidebar.)
i configured GP to display one column of posts and added the following code-snippet:
add_filter( 'generate_blog_columns','tu_portfolio_columns' ); function tu_portfolio_columns( $columns ) { if ( is_archive() ) { return 50; } return $count; }
it worked fine, until i added a woocommerce shop. now on the shop-page the woocommerce columns would only display 50% wide. it seems, that is_archive also affects the shop_page.
is there a way have different settings for displaying columns between archives (2 columns) / blog-homepage (1 column) and the woocommerce shop-page (1 column and three products in a row, which can be configured easily and seperately through customizer)?
and my second question: because i am using two columns for archives: i would need to display the double amount of posts for the archive pages (or only half the posts on home page.) how can i achieve this?
any help is appreciated.
thanks, horstDecember 1, 2018 at 7:05 pm #745720TomLead DeveloperLead DeveloperHi there,
Thanks for renewing!
Try this as your function:
add_filter( 'generate_blog_columns', function( $columns ) { if ( function_exists( 'is_shop' ) && is_shop() ) { return $columns; } if ( is_archive() ) { return 50; } return $columns; } );
For your second question, try this:
add_action( 'pre_get_posts', function( $query ) { if ( ! $query->is_main_query() || is_admin() ) { return; } if ( $query->is_archive ) { $query->set( 'posts_per_page', 20 ); } }, 1 );
You can adjust the
posts_per_page
to whatever.Let me know if that helps or not π
December 2, 2018 at 1:29 am #745814horstthanks tom for your fast reply!
problem number one is solved! thanks!
for the second problem -> the number of posts:
with your code snippet i am getting a white screen…
i also tried another code from the support forum before:
add_filter('pre_get_posts', 'posts_on_page', 1); function posts_on_page($query){ if ( $query->is_home() && $query->is_main_query() && ! is_admin() ) { $query->set( 'posts_per_page', 12 ); } if ( $query->is_page( 'archiv' ) ) { $query->set( 'posts_per_page', 24 ); } }
no white screen with it, but it displays also 24 instead of 12 post on my home/blogpage. (btw: i configured wordpress to display 12 posts, but with the code-snippet this number has also no effect…)
thanks again for your help!
horstDecember 2, 2018 at 8:51 am #746112TomLead DeveloperLead DeveloperStrange – I just made an adjustment to my code, can you give it another shot?
December 2, 2018 at 2:30 pm #746284horstthanks tom, the new code works perfectly!
i have a small other problem (on a different site running GP as well) obviously because of the migration from the local machine to the live-server: there are two links of images referring to localhost (in the header), but i cant find where to change them.
should i open a new support ticket?
thanks for you help!
December 2, 2018 at 4:20 pm #746322LeoStaffCustomer SupportGonna take a blind guess here…check mobile header logo and navigation logo:
https://docs.generatepress.com/article/mobile-header/
https://docs.generatepress.com/article/navigation-logo/If not new topic please π
December 4, 2018 at 4:11 am #747593horstthanks again tom & leo,
eventhough there where no entries in the mobile header with navigation logo (no image selected) i enabled it, disabled it, set a new image (from the server), deleted it.
after that: and no more localhost entries in the code.
thanks a million, and what a great support.
all problems solved.
best, horst
December 4, 2018 at 10:04 am #747975LeoStaffCustomer SupportGlad we could help π
-
AuthorPosts
- You must be logged in to reply to this topic.