- This topic has 21 replies, 2 voices, and was last updated 6 years, 7 months ago by
Tom.
-
AuthorPosts
-
August 23, 2019 at 9:30 am #991727
Patrick
Hehe yes thats my ticket, I’ve asked they this morning ๐
I give them a try this evening ๐
August 23, 2019 at 12:05 pm #991826Patrick
Hi Tom,
we getting closer, but there is one problem with featured images and pagination. The last 3 adverts have featured images:
If I use the following code as archive-adverts.php it looks good, the pagination works, but the featured Images are not shown.
<?php /** * The template for displaying Archive pages. * * @package GeneratePress */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } get_header(); ?> <div id="primary" <?php generate_do_element_classes( 'content' ); ?>> <main id="main" <?php generate_do_element_classes( 'main' ); ?>> <?php /** * generate_before_main_content hook. * * @since 0.1 */ do_action( 'generate_before_main_content' ); if ( have_posts() ) : /** * generate_archive_title hook. * * @since 0.1 * * @hooked generate_archive_title - 10 */ do_action( 'generate_archive_title' ); while ( have_posts() ) : the_post(); /* * 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() ); endwhile; /** * generate_after_loop hook. * * @since 2.3 */ do_action( 'generate_after_loop' ); generate_content_nav( 'nav-below' ); else : get_template_part( 'no-results', 'archive' ); endif; /** * generate_after_main_content hook. * * @since 0.1 */ do_action( 'generate_after_main_content' ); ?> </main><!-- #main --> </div><!-- #primary --> <?php /** * generate_after_primary_content_area hook. * * @since 2.0 */ do_action( 'generate_after_primary_content_area' ); generate_construct_sidebars(); get_footer();If I use the following code for the archive-advert.php, the columns and masonry not working correct, but the featured images are shown.
<?php if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } get_header(); ?> <div id="primary" <?php generate_do_element_classes( 'content' ); ?>> <main id="main" <?php generate_do_element_classes( 'main' ); ?>> <?php /** * generate_before_main_content hook. * * @since 0.1 */ do_action( 'generate_before_main_content' ); $args = array('post_type' => 'advert'); $myQuery = new WP_Query($args); if ( $myQuery->have_posts() ) : while ( $myQuery->have_posts() ) : $myQuery->the_post(); /* 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', 'advert' ); endwhile; /** * generate_after_loop hook. * * @since 2.3 */ do_action( 'generate_after_loop' ); generate_content_nav( 'nav-below' ); else : get_template_part( 'no-results', 'index' ); endif; /** * generate_after_main_content hook. * * @since 0.1 */ do_action( 'generate_after_main_content' ); ?> </main><!-- #main --> </div><!-- #primary --> <?php /** * generate_after_primary_content_area hook. * * @since 2.0 */ do_action( 'generate_after_primary_content_area' ); generate_construct_sidebars(); get_footer();=> Like to have the first one WITH featured images, than I’m happy
Admin credentials which i send you yesterday already working ๐
August 23, 2019 at 7:34 pm #991972Tom
Lead DeveloperLead DeveloperCan we try replacing the
get_template_part()again?:get_template_part( 'content', 'advert' );The necessary hooks to display the featured images should be in there.
Let me know ๐
August 23, 2019 at 7:40 pm #991978Patrick
sure, i’ve changed it again, but there are also no featured images.
They only visible if I use the custom loop. WPAdverts uses featured images something strange.you can everytime change what you want on the site i send you the credentials ๐
August 25, 2019 at 9:09 am #993052Tom
Lead DeveloperLead DeveloperLet’s try this:
add_filter( 'generate_featured_image_output', function( $output ) { if ( is_post_type_archive( 'advert' ) && function_exists( 'adverts_get_main_image' ) ) { $output = sprintf( // WPCS: XSS ok. '<div class="post-image"> <a href="%1$s"> <img src="%2$s" alt="" /> </a> </div>', esc_url( get_permalink() ), adverts_get_main_image( get_the_ID() ) ); } return $output; } );Let me know ๐
August 25, 2019 at 9:17 am #993061Patrick
Hey Tom,
Thank you very much, this looks good.
Best regards
PatrickAugust 25, 2019 at 4:09 pm #993334Tom
Lead DeveloperLead DeveloperYou’re welcome ๐
-
AuthorPosts
- You must be logged in to reply to this topic.