- This topic has 3 replies, 2 voices, and was last updated 4 years, 3 months ago by
Tom.
-
AuthorPosts
-
February 5, 2019 at 1:02 am #801724
Guillem
I love generatepress Congratulations to all of the team. I am sorry for my English, I am Catalan and I do not speak English.
I have created a CPT (professors) and I want to show the image after the title in the archive file. I have created archive-professors.php and content-professors-php. For the moment I have only changed to archive-professors:
get_template_part (‘content-professors’, get_post_format ());The problem is that I do not understand much code and I do not find where I need to modify the order as and how the elements (image, title and excerp) are displayed.
I do not want to use the customize of generatepress, because I want it to be different from the entries.
Can you help me? I know it must be a very simple thing but I do not find it.Thank you very much and forward !!
February 5, 2019 at 8:41 am #802227Tom
Lead DeveloperLead DeveloperHi there,
Are you wanting to move the featured image below the title, only in the archives of that custom post type?
If so, you shouldn’t need custom template files. Try something like this:
add_filter( 'option_generate_blog_settings', function( $options ) { if ( is_post_type_archive( 'professors' ) ) { $options['post_image_position'] = ''; // Empty is below title by default } return $options; } );
Adding PHP: https://docs.generatepress.com/article/adding-php/
February 6, 2019 at 2:04 am #802771Guillem
Thanks for the quick reply,
Ok, I understand. But I wanted to put the image on top of the title. I did not express myself very well.
What I did and what I did was write the code in file-professors.php. This makes it easier for me to personalize with specific css.
The code is correct or I have done something wrong.
<?php /** * The template for displaying professors Category pages. * * Learn more: http://codex.wordpress.org/Template_Hierarchy * * @package GeneratePress */ // No direct access, please if ( ! defined( 'ABSPATH' ) ) exit; get_header(); ?> <section id="primary" <?php generate_content_class(); ?>> <main id="main" <?php generate_main_class(); ?>> <?php do_action('generate_before_main_content'); ?> <?php if ( have_posts() ) : ?> <?php do_action( 'generate_archive_title' ); ?> <div class="inside-article"> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <div class="teachers-loop"> <div class="teachers-loop-img"> <?php the_post_thumbnail();?> </div> <div class="teachers-loop-text"> <h2><?php the_title(); ?></h2> <h4><?php the_field('materies'); ?></h4> <p><?php the_content(); ?></p> </div> </div> <?php endwhile; ?> </div> <?php generate_content_nav( 'nav-below' ); ?> <?php else : ?> <?php get_template_part( 'no-results', 'archive' ); ?> <?php endif; ?> <?php do_action('generate_after_main_content'); ?> </main><!-- #main --> </section><!-- #primary --> <?php do_action('generate_sidebars'); get_footer();
February 6, 2019 at 10:37 am #803269Tom
Lead DeveloperLead DeveloperThat will definitely work as well – especially if you want the custom classes etc.. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.