Announcement

Collapse
No announcement yet.

Featured Image on Categories/Tags pages

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Featured Image on Categories/Tags pages

    Hi -

    A few years ago, I changed the look of my posts to have a full-width featured image on every post and page. But, that doesn't translate to tags and category pages. Is it possible to do it for those pages too?

    I'm trying to create either the same or similar look on those tags/category pages.

    Here are two sample links:

    The look of my posts: https://www.globotreks.com/destinati...ng-california/
    The current look of my category pages: https://www.globotreks.com/category/...united-states/

    Also, for example, when you go to the category/tag page, it doesn't say which category it is. Can I add, for example on that link above, the title of "United States" (similar to how it looks in the posts).

    Cheers!
    Norbert


    Last edited by fuseconcepts; 12-06-2017, 10:28 PM. Reason: categories, tags, featured image, style

  • #2
    A few years ago, I changed the look of my posts to have a full-width featured image on every post and page.
    Sorry, but there´s not enough details about how you did that? PHP code? Plugin? If it´s a plugin, is it able to address tags and category pages (probably have a look at the plugin homepage again)?

    Comment


    • #3
      Sure, sorry about that. So, if I remember correctly, and I'm not missing anything, it was done by creating a hook box placed in "genesis_after_header" with the following php:

      PHP Code:
      <?php
      // Remove entry title from its default location
      remove_action'genesis_entry_header''genesis_do_post_title' );
      ?>

      <section id="hero" style="background-image: url(<?php echo wp_get_attachment_urlget_post_thumbnail_id() ); ?>)">
          <div class="overlay">
              <div class="wrap">
                  <?php genesis_do_post_title(); ?>
              </div>
          </div>
      </section>


      This has a conditional selected that I called "singular_with_featured_image" that has this tag: is_singular() && has_post_thumbnail()

      Then, on the css I have this for styling:


      Code:
      #hero {
          padding-top: 150px;
          color: #FFF;
          font-family: Lato, sans-serif;
          text-transform: uppercase;
          text-align: center;
          background-repeat: no-repeat;
          background-position: center center;
          background-attachment: fixed;
          -webkit-background-size: cover;
          -moz-background-size: cover;
          -o-background-size: cover;
          background-size: cover;
      
      }
      
      .overlay {
          padding-top: 200px;
          padding-bottom: 30px;
          background: url(https://www.globotreks.com/wp-content/uploads/dynamik-gen/theme/images/overlay.png) repeat-x top center;
          -webkit-background-size: cover;
          -moz-background-size: cover;
          -o-background-size: cover;
          background-size: cover;
      
      }
      
      #hero .wrap {
          max-width: 880px;
          margin: 0 auto;
      
      }
      
      #hero .entry-title {
          letter-spacing: -1px;
          font-weight: 300;
          font-size: 50px;
          line-height: 1;
      
      }


      So, I think I might have answered half of my question here. I guess I can create two new conditionals for "is_category" and "is_tag" so it displays the hook box there too, but what I'm still missing is how to add a featured image and title (which can be the actual tag/category name) to those pages? Is that possible? And if so, would it be the same featured image for all categories/tags or can I customize it according to the country/category?

      Thanks!
      Norbert

      Comment


      • #4
        I would suggest to have a look at the plugin “Blox Lite“. It's specifically for Genesis and works with its hooks. Look out for a tut or video explaining exactly what you want - it would save you from writing a lot of code.

        Comment


        • #5
          Thanks! I've installed the plugin and gave it a try, and I have to say it's pretty much doing what I want. Here's an example page: https://www.globotreks.com/category/destinations/peru/

          My preference, though, would be to accomplish the same without the use of a plugin. I'm trying to minimize them to try to improve the site's performance. And, while the plugin is doing what it's supposed to do, I think it's slowing down the response on the pages where it's used. (or maybe it's just me being picky about the laggy loading)

          Now, is there a way to "copy" the code (or something similar) and hardcode it using the hook boxes or something like that?

          Lastly, is there a way to have the title to say "Peru" instead of "Category: Peru"? (base on the example linked here)

          Cheers!

          Comment


          • #6
            I'm out of house and on phone the whole weekend so I can't help with code. Sure doable but quite some PHP with different images for different categories and different titles.
            So all I can say is that I'm sure you'll find code snippets for that if you do a google search but I'm not sure those won't be from membership sites though.
            Last edited by SiGa; 12-08-2017, 10:31 AM.

            Comment


            • #7
              Take a look here - https://wordpress.stackexchange.com/...-archive-title

              the first answer might be what you want for that , that would go in custom functions

              Comment

              Working...
              X