Viewing 21 posts - 1 through 21 (of 21 total)
  • Author
    Posts
  • #868655

    Hi there,

    On http://www.annemarievanderheijden.com we’ve used posts with (among others) category “recensies” (= testimonials). There is a specific page “Recensies”. Once you click on a single testimonial, you see “Berichten” (= news) as page title. Also the page “Berichten” in the menu is higlighted as being active.

    Is it possible for “recensies” to show “Recensies” as page title and highlight the page “Recensies” when it concerns “recensies”?

    Thanks for your advise.

    Regards,
    Monique

    #869443

    Hey Monique,

    Thank you for using Enfold.

    This is possible but it will require a custom modification. Please refer to the following thread.

    // https://kriesi.at/support/topic/menu-and-category-menu-items-issues/#post-851822

    We added a unique body class attribute to the posts that belongs to a certain category and then use it to modify the style of the related menu item.

    Best regards,
    Ismael

    #870557

    Hey Ismael,

    I followed the instructions from the topic mentioned. Unfortunately it does not work as required. Attached a screenshot of the single testimonial. There are two remarks:

    1. The page title should read Recensies (in stead of Berichten).
    2. The style of the menu should be that Recensies looks as Berichten on the website/screenshot. An active page in the menu should be bold and no border-bottom. Now it is normal with border-bottom. And the page Berichten is still bold…

    There is another issue we need to take into consideration: the recensies consist of different categories. My client wants to show all reviews for each book together in it’s own area on the Recensies page. The only way to do that was to create different categories for each book and place them as masonry grids on the page.

    Please advise.

    Best regards,
    Monique

    #871924

    Hi,

    Thank you for the info. Please remove the previous modifications then use the following filter instead.

    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title($args,$id)
    {
        if ( has_category( 'CATEGORY OF THE POST HERE' ) && is_single() )
        {
            $args['title'] = "Recensies";
       }
        return $args;
    }

    Replace the has_category value with the slug or name of the “Recensies” category.

    Best regards,
    Ismael

    #873829

    Hi Ismael,

    Thanks! We’re getting there :-)

    Can I add more categories to show page title “Recensies”? For example something like (perhaps):

    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title($args,$id)
    {
        if ( has_category( 'CATEGORY1', 'CATEGORY2' ) && is_single() )
        {
            $args['title'] = "Recensies";
       }
        return $args;
    }

    Best regards,
    Monique

    #874017

    Hi,

    Yes, you can add more categories but you have to put them inside an array.

    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title($args,$id)
    {
        if ( has_category( array( 'cat1', 'cat2' ) ) && is_single() )
        {
            $args['title'] = "Recensies";
       }
        return $args;
    }

    // https://codex.wordpress.org/Function_Reference/has_category

    Best regards,
    Ismael

    #874089

    Hi Ismael,

    That works great :-)

    One more thing: is it possible to show also the corresponding active page in the menu? Now in the menu you still see “Berichten” as active page (bold) as where the active page should be “Recensies”.

    Thanks & have a nice day!
    Monique

    #874198

    Hi Ismael,

    My client was here this morning and struggled to accept the fact that we would have to create/change the array for all separate categories all the time. This would mean that each time she creates a new category, she would have to ask me to change the functions.php, which doesn’t seem very workable.

    So we’ve investigated what could be a workable solution. The idea is that now we present all reviews in one overview on the “Recensies” page (see link below) as well as we present for each book/portfolio the reviews for that specific book/portfolio (see link below).

    For the Recensies page we’ve created a main category in posts called “Recensies”.
    For the single book/portfolio we’ve created sub categories in posts, in the example called “Recensie Noortje en de paaseitjes”.

    After these changes we’ve noticed that the code you’ve provided (#post-871924) does no longer work properly: the single post for “Recensies” now shows again “Berichten” as page title… I hope you are still able to follow what I mean ;-)

    Sorry for this, but can you help again please? And see also my question about active menu item for “Recensies”.

    Best regards,
    Monique

    #874463

    Hi,

    I’m sorry but that is basically the same setup. However, this time you need to use the “has_term” instead of the “has_category” function because you’re using the portfolio custom post type.

    Best regards,
    Ismael

    #874572

    Hi Ismael,

    We’re not using portfolio custom post type to create the “recensies”, we’re using normal posts with category “recensies”.

    Still I tried your suggestion to change “has_category” to “has_term”, but that doesn’t work.

    Please advise.

    Best regards,
    Monique

    #875024

    Hi,

    We’re not using portfolio custom post type to create the “recensies”, we’re using normal posts with category “recensies”

    The following post is a portfolio item. Is that one of the “recensies”? ( see private field )

    Best regards,
    Ismael

    #875059

    Please see below.

    #875927

    Hi,

    Thank you for the info. You have to use the same filter and use the slug name of the category in the “has_category” function.

    Best regards,
    Ismael

    #877634

    Hi,

    I am loosing track a bit… :-(

    What do you mean by ‘you have to use the same filter’?

    Since the slug name is ‘recensies’, do you mean that I have to go back using following code:

    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title($args,$id)
    {
        if ( has_category( 'recensies' ) && is_single() )
        {
            $args['title'] = "Recensies";
       }
        return $args;
    }

    I’ve tried that, but it doesn’t work.

    Please advise.

    Thanks & regards,
    Monique

    #877959

    Hi,

    Ok. Let’s step back a little because I’m getting a little bit confuse too. Please provide a link to the actual post or page where you want to change the title. If you’re using the portfolio item, you have to replace the “has_category” function with “has_term”.

    Best regards,
    Ismael

    #878072

    Hi,

    See below. These reviews are all created by posts with main category “recensies”.

    They also have a subcategory, but that has another reason and is (as far as I can see) not applicable for changing the post title.

    Best regards,
    Monique

    #878412

    Hi,

    Thank you for the info.

    The actual category of the post ( see private field) is “recensies-noortje-en-de-paaseitjes” so you have to use that as the value of the has_category function instead of “recensies” unless you also applied “recensies” as the category of the post. Are you trying to apply the modification to the sub or child categories of the “recensies” category?

    Best regards,
    Ismael

    #880214

    Hi Ismael,

    I understand what you’re saying. So for all reviews I’ve now activated both the main category (“Recensies”) and the child category. Strangely enough this works for two of the existing reviews but not for the other two (see below).

    As a reminder, the code which we now have in Child functions.php is:

    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title($args,$id)
    {
        if ( has_category( 'recensies' ) && is_single() )
        {
            $args['title'] = "Recensies";
       }
        return $args;
    }

    One more remark: also the two reviews that now give the correct page title, still has the bold active status of “Berichten” in the menu. Is there something that can be done to also change that?

    Thanks & regards,
    Monique

    #881045

    Hi,

    The has_category value is still set to “recensies-noortje-en-de-paaseitjes”. We changed it to “recensies”.

    Best regards,
    Ismael

    #915457

    Hi,

    Just “cleaning” my old posts…

    Can you please flag this topic as closed?

    Thanks & regards,
    Monique

    #915822

    Hi,

    Thank you for the update. We’ll close the thread now.

    Have a nice day! :)

    Best regards,
    Ismael

Viewing 21 posts - 1 through 21 (of 21 total)
  • The topic ‘Is it possible to show category name as page title?’ is closed to new replies.