• Hello –

    I’ve created a website using the Gazette template at: http://celticknothypnosis.com. So far, working with the template is very easy – good job team!

    However, as you can see at the website, I’ve removed the right-hand side navbar, so the site behaves more like a website than a blog. Is there anyway that I can still make a nice collage of the pics at the top like the demo?

    https://gazettedemo.wordpress.com/

    Thanks in advance for any help. Cheers,

    Clive

Viewing 15 replies - 1 through 15 (of 15 total)
  • Hi @ironclive!

    You can, yes 🙂

    First, make sure you have the Jetpack plugin installed. Once that is activated, you’ll find a “Featured Content” section in your Customizer.

    You can use that section to set a Featured Content tag. Add that tag to whatever posts you’d like to see at the top of the page – then the Featured Images of those posts will appear, linking to the posts themselves 🙂

    Thread Starter ironclive

    (@ironclive)

    Chad – Thanks so much for the reply!

    I have installed Jetpack successfully and it seems like everything is working properly (i.e. there is a featured content section in my customize tab).

    I am using using this template slightly different than a traditional “blog” site – I’m using it build literally a “flat” website. As such, i dont have blog pages …

    Can I have those images at the top of the page, linking to static pages on my website?

    i.e. have an ‘services’ image at the top which simply links to …

    http://celticknothypnosis.com/services/

    Possible?

    Thanks in advance for your help,

    Clive

    Hi @ironclive!

    It’s doable, yes, but will take a bit of coding. You’ll want to start by creating a child theme.

    In that child theme, we’ll need to do a few things. First, we need to add Tag support to your pages. Then we need tell the Featured Content section to include pages in its search (instead of just posts).

    First, in your child theme’s functions.php file, we’ll add the following:

    // Add tags to pages
    function tags_on_pages() {
        register_taxonomy_for_object_type('post_tag', 'page');
    }
    
    add_action('init', 'tags_on_pages');
    
    // Add pages to Featured Content
    function add_featured_pages() {
        add_theme_support( 'featured-content', array(
            'filter'      => 'gazette_get_featured_posts',
            'description' => __( 'The featured content section displays on the front page above the header.', 'gazette' ),
            'max_posts'   => 6,
            'post_types'  => array( 'post', 'page' ),
        ) );
    }
    
    add_action( 'after_setup_theme', 'add_featured_pages', 20);

    At this point, you’d be able to see a featured page up in that top section, but it wouldn’t have its image. The theme uses a bit of javascript to apply the background images, and that script isn’t looking for pages – just a selection of post formats.

    Your first step to fixing that will be to copy a file from the child theme: /js/featured-contnt.js into your child theme folder. Don’t worry about making a /js/ folder for it, we don’t have enough files going in here to make that necessary. Just drop it right into the main child theme folder.

    Now, open your copy of the file and look at line 35 (of the current version of the theme, it could potentially shift a bit in future updates).

    If you read across that line you’ll see it checking for post formats (like 'format-image', 'format-gallery' and so on). We’re going to add a little bit onto the end to have it look for pages as well. Replace that line with this one:

    		if ( ! $( this ).hasClass( 'background-done' ) && $( this ).hasClass( 'has-post-thumbnail' ) && ( $( this ).hasClass( 'format-image' ) || $( this ).hasClass( 'format-gallery' ) || $( this ).hasClass( 'format-standard' ) || $( this ).hasClass( 'format-video' )  || $( this ).hasClass( 'page' ) ) ) {
    

    All we’ve done is added a check for 'page' as a class – since that’s the class a page would have!

    The last step is to tell the child theme not to use the original copy of the file you just edited, and use your copy instead. Back in your child theme, add the following:

    function my_featured_js() {
        // Dequeue the original
        wp_dequeue_script( 'gazette-featured-content' );
        // Enqueue the new
        wp_enqueue_script( 'my-gazette-featured-content', get_stylesheet_directory_uri() . '/featured-content.js', array( 'jquery' ), '20150507', true );
    }
    
    add_action( 'wp_enqueue_scripts', 'my_featured_js', 12 );
    

    Now you should see pages in your Featured Content (remember, they’re listed in the order they were published, so if you have Featured Posts that are newer than your Featured Page(s), they might not show up).

    Give it a try and let me know how it goes!

    Thread Starter ironclive

    (@ironclive)

    Thanks @shireling!

    I will try tomorrow and let you know how it goes!

    Cheers, Clive

    You’re welcome! I’ll cross my fingers for you 🙂

    Thread Starter ironclive

    (@ironclive)

    Hi Chad – I’m good up until virtuall the last step. Line 35 in my featured-content.js file is …

    if ( ! $( this ).hasClass( ‘background-done’ ) && $( this ).hasClass( ‘has-post-thumbnail’ ) && ( $( this ).hasClass( ‘format-image’ ) || $( this ).hasClass( ‘format-gallery’ ) || $( this ).hasClass( ‘format-standard’ ) || $( this ).hasClass( ‘format-video’ ) ) ) {

    What am I changing this to (or adding)?

    Clive

    We’re adding one more condition to the end. When you look through that line you’ll see || a bunch of times. That means or.

    What this line basically does is say If this item has an image ready, and it’s an image post, or a gallery post, or a standard post, or a video post, do a bunch of stuff.

    We want to add (in code) …or if it’s marked that it’s a page.

    Starting from the last $( this ).hasClass you have now, it should read like this:
    $( this ).hasClass( 'format-video' ) || $( this ).hasClass( 'page' ) ) ) {

    Or, you can just replace the entire line with the example from my previous post, it has the page check in there.

    If you add it in manually, make sure you have the right number of parenthesis in the right places 🙂

    Thread Starter ironclive

    (@ironclive)

    Thanks @shireling. I believe I’ve followed all of your steps correctly, yet I do not see pages in my “featured content” menu. Is there anything else I have to enable?

    Cheers mate,

    Clive

    Thread Starter ironclive

    (@ironclive)

    Sorry, let me give you some more information.

    I created the “featured” tag, then went to specific pages and added the tag “featured”. I then added a featured image for each of those pages. Now, it is showing just that image (i.e. the services featured image on the services page). I just wanted that nice collage of images on my homepage :).

    http://celticknothypnosis.com

    Thanks in advance (again) for all of your help.

    Clive

    Thread Starter ironclive

    (@ironclive)

    Solved it! I had to switch my home page from static to “your latest posts” and it worked!

    Thanks so much!

    Clive

    You’re welcome! 🙂

    Hi! could you please give me a detailed description of developing the collage at the top of the page ? Jetpack installed. All instructions on changing the code executed.

    Hi @alexgrishkevich

    With Jetpack installed, you’ll want to open your Customizer and look in the Featured Content section.

    Use the provided field to set a Featured Content tag (featured is a popular choice).

    Next, edit the posts (or in this case, with our modifications posts/pages) you want to put in the top section of the home page.

    Give each post/page a Featured Image, and add the tag you set in the Customizer

    The posts/pages with the correct tag will now appear with their Featured Images at the top of the home page. If not, make sure you’ve set your home page to show Your latest posts under Settings > Reading like @ironclive mentioned 🙂

    @shireling Thanks you. This information helped me

    You’re welcome!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Create header of images like demo’ is closed to new replies.