[Resolved] Link Category to a specific page – not the archive page

Home Forums Support Link Category to a specific page – not the archive page

  • This topic has 41 replies, 3 voices, and was last updated 1 year ago by Tom.
Viewing 15 posts - 1 through 15 (of 42 total)
  • Author
    Posts
  • #942257
    Max

    Hi there!

    I am using the latest version of GP Premium. I looked through some forum posts and the suggested ones while opening this topic but could not solve the issue. I am not quite sure whether it is a WP, plugin or or a GP problem.

    What I want to do:
    I have installed a plugin which shows on my homepage (Post Carousel Pro). There, the three different categories for the types of posts I publish on my website are being display (science posts, stray observations, all posts).
    Once I click on one of those categories (within the posts carousel on my homepage or any other post grid/list created with the PCP plugin) I am being redirected to the archive page of that specific category. The same happens if I click on a specific category once the archive page shows, or when I click on a category which is displayed under a published WP post. I guess that is why it is probably not just an issue with the plugin.
    What I would like to happen instead is: Once I click on the according category I would like to be redirected to a specific page, e.g. in the case of “science posts” to the “science posts” overview page which I created with the help of the PCP plugin (It can be accesses via the top menu) instead of the archive page of “science posts” which gets created/generated automatically.
    Is there any way to make that that happen?

    Your help would be much appreciated.

    Best regards

    #942311
    David
    Staff
    Customer Support

    Hi there,

    that is the normal WP behaviour of a category link, that is to take you to the category archive. Tom did find a solution for another user with a similar request here:

    https://generatepress.com/forums/topic/replace-default-post-category-template-with-a-blank-page-template/#post-608201

    #942951
    Max

    Thanks for the fast response, David.

    I will have a look.

    #942977
    David
    Staff
    Customer Support
    #942986
    Max

    Nr. 3 worked like a charm and it was super easy to use.

    Thanks for the hint!

    #942992
    David
    Staff
    Customer Support

    Awesome – glad that worked out 🙂

    #976072
    Max

    Hi David!

    Since it is a related topic I reopened the thread:

    I discovered (better late than never) that tags behave in a similar way to categories. Now, I cannot create an individual archive page for each tag but would there be a way to create a simple post list instead of a grid when being redirected to a “tag archive page”?

    Thank you

    #976079
    David
    Staff
    Customer Support

    You can use the Blog Options filter:

    https://docs.generatepress.com/article/option_generate_blog_settings/

    The example provided is for the search page is_search() for tag archives you can use the is_tag() conditional

    #976854
    Max

    Hi David!
    I added the filter and so far it is working out nicely.

    1.) Would it be possible to change the list view? Mainly, I would like to decrease the size of the images and basically move them to the side so that they would be aligned like in this example: https://www.fraunhofer-innovisions.de/?s=&tag=2545&detail=true&type=post

    2.) Would it be possible to change the attributes of the title/meta data, so basically styling the post title, date and author like we figured out in this post? :
    https://generatepress.com/forums/topic/styling-single-post-page/#post-976814

    3.) I enabled the “read more” button but it does not show. In most posts I am using the WP excerpt function. Is that what is meant with “custom excerpt” in this post: https://docs.generatepress.com/article/activating-read-custom-excerpt/ ?

    I also enabled the “load more” button but it does not show. Is that because of the lack of results or due to another reason? E.g.: https://alexandrin.de/tag/big-city-life/
    Would it be possible to manually limit the amount of search results in order to make the “load more” button appear earlier?

    #976900
    David
    Staff
    Customer Support

    1. So with the blog options you can set the image position (above header) and alignment (left). Then use the filter provided here to change the size of the featured image – again using the is_tag() conditional:

    https://docs.generatepress.com/article/adjusting-the-featured-images/#changing-the-featured-image-sizes-using-a-filter

    2. The styling for the meta tags in the other post should flow down to the tag archive.
    If you want to specifically target the title on the archive then use ( add ) this CSS selector:

    .archive.tag .entry-title

    3. Custom Excerpt or Manual Excerpt ( the same thing ) is when you use the Excerpt metabox in the post editor. It requires that custom function.

    4. All of the archives will display the number of posts you define in Dashboard > Settings > Reading. If you want to change it specifically for the tag archive then try this PHP snippet:

    function wpsites_query( $query ) {
    if ( $query->is_tag() && $query->is_main_query() && !is_admin() ) {
            $query->set( 'posts_per_page', 6 );
        }
    }
    add_action( 'pre_get_posts', 'wpsites_query' );
    #981994
    Max

    Hi again!

    Apologies for the long delay – I am currently on vacation and only check back in sporadically.

    1.) I added the filter and it works. I just want to find a way to make it look tidy, e.g. by limiting the word number of the excerpt/displyed preview of the post text in order to let it align with the featured image. I will try around a bit and will get back to you on that.

    2.) Ok – I will take a look once I have changed the styling and thank you for the specific selector.

    3.) Good to know!

    4.) Changing the displayed post number did the trick. But in case I want to target the archive page manually the snippet will come in handy – in any case the snippet works!
    Do you know of a way to style the “Read More” button which is enabled due to the previous filter? I want to change the font and background colour and perhaps the opacity etc.

    #982389
    David
    Staff
    Customer Support

    1. You can use the filter with the same conditional is_tag() to change the excerpt for that archive:

    https://docs.generatepress.com/article/excerpt_length/#examples

    5. Read More styling – is this for the standard blog ( as currently the tags archive isn’t showing one ) or for the plugin you’re using for the carousels etc. ?

    #985037
    Max

    Hi David!

    1-3.) I tried around a bit and managed to manipulate the featured image and the meta data.
    The things that did not work:
    – changing the colour of the entry title on the tag archive page; I used the following code:

    .archive.tag .entry-title {
        font-size: 20px;
        color: rgb(206,169,47);
    }
    

    I also tried other colours (red, black) which did not work either.

    – limiting the excerpt length. I used the following code:

    
    add_filter( 'excerpt_length','lh_custom_category_excerpt_length', 1000 );
    function lh_custom_category_excerpt_length( $length ) {
        if ( is_tag() ) {
            return 14;
        } 
        return $length;
    }
    

    I also altered the numbers but no combination showed any effect.
    I still have to try out adding the read more button though.

    4.) I was not specific enough: I meant the “More results” button at the bottom of the tag archives page which was added due to the php filter which you pointed me at in this post. If you open this tag archive page: https://alexandrin.de/tag/big-city-life/ you will see the button at the bottom.

    5.) Is it possible to remove the copyright note of the featured image just on the tag archive page? It does not need to be displayed there and just consumes space.

    #985644
    David
    Staff
    Customer Support

    2. change the selctor to this: .archive.tag .entry-title a

    3. Sorry my bad, wasn’t thinking – the Manual Custom excerpt will not be effected by that filter. It only applies to the automatic excerpt that WP creates.

    4. The Load more button you can style like so:

    .load-more a {
        background-color: rgb(206,169,47);
    }

    5. Was the copyright added using a Hook Element? If so you can exclude the Tag Archive from the Display Rules.

    #986818
    Max

    2.) The selector worked – thanks!

    3.) Is there any way to limit the number of words that are being displayed there, so targeting the manual excerpt specifically? I managed to change the font color/size using the .entry-summary selector and left them this way for now.

    4.) Thank you – that worked!

    5. I described how I added the copyright in this post: https://generatepress.com/forums/topic/link-category-to-a-specific-page-not-the-archive-page/#post-985644
    It is a php snipped:

    add_action( 'generate_after_entry_header', 'db_featured_image_caption', 15 );
    function db_featured_image_caption() {
        $get_description = get_post(get_post_thumbnail_id())->post_excerpt;
        if(!empty($get_description)){    
            echo '<span class="featured_caption">' . $get_description . '</span>';
        }
    }

    and the following CSS:

    .post-image-below-header.post-image-aligned-center .inside-article .featured-image {
        margin-bottom: 0.1em;
    }
    
    .featured_caption {
        font-size: 60%;
        padding-top: 5px;
        opacity: .8;
        margin-bottom: 1.5em;
    }
Viewing 15 posts - 1 through 15 (of 42 total)
  • You must be logged in to reply to this topic.