-
AuthorPosts
-
October 25, 2017 at 11:09 am #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,
MoniqueOctober 27, 2017 at 8:08 am #869443Hey 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,
IsmaelOctober 30, 2017 at 4:31 pm #870557Hey 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:
- The page title should read Recensies (in stead of Berichten).
- 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,
MoniqueNovember 3, 2017 at 4:12 am #871924Hi,
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,
IsmaelNovember 7, 2017 at 5:10 pm #873829Hi 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,
MoniqueNovember 8, 2017 at 5:57 am #874017Hi,
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,
IsmaelNovember 8, 2017 at 10:22 am #874089Hi 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!
MoniqueNovember 8, 2017 at 2:59 pm #874198Hi 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,
MoniqueNovember 9, 2017 at 7:01 am #874463Hi,
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,
IsmaelNovember 9, 2017 at 10:08 am #874572Hi 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,
MoniqueNovember 10, 2017 at 6:43 am #875024Hi,
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,
IsmaelNovember 10, 2017 at 9:10 am #875059Please see below.
November 13, 2017 at 4:29 am #875927Hi,
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,
IsmaelNovember 16, 2017 at 6:03 pm #877634Hi,
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,
MoniqueNovember 17, 2017 at 7:21 am #877959Hi,
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,
IsmaelNovember 17, 2017 at 2:37 pm #878072Hi,
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,
MoniqueNovember 18, 2017 at 8:48 am #878412Hi,
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,
IsmaelNovember 22, 2017 at 12:34 pm #880214Hi 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,
MoniqueNovember 24, 2017 at 5:33 am #881045Hi,
The has_category value is still set to “recensies-noortje-en-de-paaseitjes”. We changed it to “recensies”.
Best regards,
IsmaelFebruary 21, 2018 at 2:30 pm #915457Hi,
Just “cleaning” my old posts…
Can you please flag this topic as closed?
Thanks & regards,
MoniqueFebruary 22, 2018 at 3:27 am #915822 -
AuthorPosts
- The topic ‘Is it possible to show category name as page title?’ is closed to new replies.