banner



How To Create A Single Post Template Generatepress

#233926

Rodrigo

Hi Tom,

How tin I create a custom single post template for a specific category?

In single posts within a specific category I'd similar to change the featured paradigm smaller and to the right and put the title and content next to it.

That specific mail service is merely going to have a paragraph description and a role player for podcast.

Is in that location a plugin or somehow I can practise that?

#233936

Tom

Lead Developer

Lead Developer

Y'all may non need a custom template.

You would need to add the category class to the unmarried post though with a function like this:

              add_filter('body_class','add_category_to_single'); function add_category_to_single($classes, $form) {     if (is_single() ) {         global $post;         foreach((get_the_category($post->ID)) as $category) {             // add category slug to the $classes array            $classes[] = $category->category_nicename;         }     }     // return the $classes assortment     return $classes; }            

Adding PHP: https://generatepress.com/knowledgebase/calculation-php-functions/

Then you could target that featured image similar this:

              .your-category-proper name .page-header-image-single {     max-width: 300px;     float: right; }            

Calculation CSS: https://generatepress.com/knowledgebase/adding-css/

That should get you started 🙂

#233950

Rodrigo

Uh WOW, that worked perfectly well…

I might demand a little flake of help, if you can.

How tin I put the image below the title, and then that way the title size volition exist 100% of the content expanse?

#233957

Tom

Lead Developer

Lead Developer

Y'all should be able to do that in "Customize > Layout > Page Header" past irresolute "Unmarried Mail service Page Header" to "Below title".

Allow me know 🙂

#233962

Rodrigo

The thing is I only need that image position in i unique category posts. On the other categories, paradigm'due south posts should be in a higher place any element, including post title.

#234068

Tom

Lead Developer

Lead Developer

That'southward a bit harder, simply yous should be able to do this:

              add_action( 'after_setup_theme','tu_category_specific_page_header' ); office tu_category_specific_page_header() {     // Only do this if nosotros're in category IDs i, two and iii     if ( in_category( assortment( 1,2,3 ) ) ) {         remove_action('generate_after_header','generate_page_header_single_above', ten);         add_action('generate_after_entry_header','generate_page_header_single_below_title', 10);     } }            

#778598

Rodrigo

I approximate this is solved with the new Elements module on GP, right?

#778773

Tom

Lead Programmer

Lead Programmer

Which office, specifically?

#995968

Rodrigo

Hullo Tom. I'm just gonna close this thread because I tin't even remember what site I was talking about here (and if is still on my hands, which I don't think so) and, honestly, I don't similar to meet the topic open. Yous know, OCD bug… n_n

How To Create A Single Post Template Generatepress,

Source: https://generatepress.com/forums/topic/custom-template-for-single-post/

Posted by: parmercombou1979.blogspot.com

0 Response to "How To Create A Single Post Template Generatepress"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel