[Resolved] Custom Intro for Each Category Archive for First Page Only

Home Forums Support [Resolved] Custom Intro for Each Category Archive for First Page Only

Home Forums Support Custom Intro for Each Category Archive for First Page Only

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #1618607
    David
    Staff
    Customer Support

    Hi there,

    the simplest method would be to hide the element with some CSS eg.

    body[class^="category-paged-"] .hero-description {
      display: none;
    }

    Then wrap your description content within a HTML Element that has the class to hidden:

    <p class="hero-description">The description</p>

    #1618649
    David

    Please stop downloading code and then hiding it with css.

    #1618663
    David
    Staff
    Customer Support

    Unless there is a fundamental SEO issue i don’t see what the problem is here, as we’re only dealing with text that only requires a simple database query.

    But there are alternatives, one of which is to create a shortcode to output the description and only output it on non paged archives eg.

    add_shortcode( 'term_description', 'tu_term_description' );
    function tu_term_description() {
      if (!is_paged()) {
        ob_start();
        echo term_description( get_queried_object()->term_id, 'category' );
        return ob_get_clean();
      }
    } 

    Which will provide you with this shortcode [term_description]

    #1618664
    David

    OK so here is a simple Element Header:

    <h1>{{post_title}}</h1>
    <p>{{custom_field.description}}</p>
    <p>
    Subscribe Now
    </p>

    I can change this to

    <h1>{{post_title}}</h1>
    <p>[show_excerpt]</p>
    <p>
    Subscribe Now
    </p>

    and write a shortcode that returns the excerpt on the first page and otherwise return empty

    Something like this:

    add_shortcode( ‘show_excerpt’, function() {
    ob_start();
    if( is_archive() && !is_paged() ) {
    echo get_the_excerpt();
    }
    return ob_get_clean();
    } );

    But this shortcode needs work!

    #1618666
    David

    OK yes, that worked. Very easy! Thank You!!!

    #1618669
    David
    Staff
    Customer Support
    #1618671
    David

    Yeah I got it thanks.

    #1618674
    David
    Staff
    Customer Support

    You’re welcome

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.