-
AuthorPosts
-
November 20, 2015 at 9:19 am #539382
Hi,
I need to remove the “Permanent Link” from all page and post H1 titles – not just the title attribute, bu the whole A tag around the text. I tried some of the advice I found on the forum, but I can’t seem to make it work.
Please note, I want to render the page without the link, which means I need a PHP solutions and not jQuery code to remove the tag, or CSS to remove the link styling.
Preferably, I would appreciate code that can be inserted into my child theme’s functions.php in order to make the change update-proof.
Thank you,
YanivNovember 20, 2015 at 2:54 pm #539651Hey yaniv691!
Please go to Appearance > Editor and open functions-enfold.php file and find
` if(!empty($link) && !empty($title)) $title = "<a href='".$link."' rel='bookmark'>".$title."</a>"; `
and change it to
if(!empty($link) && !empty($title)) $title = $title;
You can copy the whole “avia_title” function from functions-enfold.php file to functions.php file of your child theme to make the changes update-proof
Cheers!
YigitNovember 20, 2015 at 6:24 pm #539850Thanks, but this works only on pages but not on posts. How do I do the same on posts?
- This reply was modified 9 years, 1 month ago by yaniv691.
November 20, 2015 at 6:32 pm #539857Hi!
Please add following code to Functions.php file as well
add_filter('avf_title_args', 'fix_single_post_title', 10, 2); function fix_single_post_title($args,$id) { if ( $args['title'] == 'Blog - Latest News' ) { $args['title'] = get_the_title($id); $args['link'] = ""; $args['heading'] = 'h1'; } return $args; }
Cheers!
YigitNovember 20, 2015 at 6:40 pm #539865Almost, not quite there: What you sent replaces the “Blog – Latest News” title with the post title in a H1 tag. That’s great!
But, there’s another post title which is also a H1 tag and has the “Permanent Link”. I would like to remove this title completely, so the page will be rendered with only one H1.
See here:
http://yaniv.qwaisdns.com/archive1/?p=25 (see the dark grey title, just above the date)November 24, 2015 at 3:40 pm #541709Hey!
use this code in Quick CSS code:
.post-title.entry-title { display: none; }
Regards,
AndyNovember 24, 2015 at 3:47 pm #541714Thanks Andy, but this is exactly what I don’t want – two H1 tags and just hide one of them.
You can’t fool Google by hiding the addtional H1 tag with CSS. I would like the HTML of the page to be rendered with only one H1 tag.
Thanks!
November 24, 2015 at 3:49 pm #541715Hi!
Please try adding following code to Functions.php file as well
add_filter('avf_title_args', 'fix_single_post_title_h1', 10, 2); function fix_single_post_title_h1($args,$id) { if (is_single()) { $args['title'] = get_the_title($id); $args['link'] = ""; $args['heading'] = 'span'; } return $args; }
Cheers!
YigitNovember 10, 2016 at 10:51 pm #710925this code in the functions.php works for me to remove the link from the headings:
add_filter(‘avf_title_args’, ‘fix_single_post_title_h1’, 10, 2);
function fix_single_post_title_h1($args,$id)
{
if (is_single())
{
$args[‘title’] = get_the_title($id);
$args[‘link’] = “”;
$args[‘heading’] = ‘span’;
}return $args;
}thanks for this! however, it changes the posts page title where all the posts are displayed from “blog” to the main title of the most recent post. any fix for this?
November 10, 2016 at 10:59 pm #710926Hey!
Please remove following line from your code
$args[‘title’] = get_the_title($id);
Cheers!
YigitNovember 10, 2016 at 11:20 pm #710928i tried removing that line, and now all of the links are back. any other ideas? i am using only that code in the functions.php
November 10, 2016 at 11:24 pm #710929ok i got it i believe!
used this:
add_filter(‘avf_title_args’, ‘fix_single_post_title’, 10, 2);
function fix_single_post_title($args,$id)
{
$args[‘link’] = “”;
$args[‘heading’] = ‘h1’;return $args;
}will let you know if anything else comes up, thanks!!
November 11, 2016 at 1:38 am #710950Hi,
Glad it worked for you! :)
We will keep the thread open and will wait to hear from the creator of this thread. If you have any other questions or issues, please feel free to start a new thread.
Best regards,
YigitDecember 10, 2016 at 5:27 pm #722721hi, i am back,
any chance on how to also remove the links from the blog post titles?
December 13, 2016 at 12:59 pm #723690Hi,
Would you mind providing a precise link to your site, showing the elements in question? We need to be able to inspect them in order to help :)
Best regards,
AndyDecember 14, 2016 at 1:01 am #724050There is the link, i have already set the heading of blog to not show, now i am talking about the post title. thanks!
December 14, 2016 at 7:49 pm #724480Hi,
use this code:
.post-title.entry-title { display: none; }
Best regards,
AndyDecember 14, 2016 at 8:48 pm #724532I dont want a css code, i am looking for a function similar to the one already posted to remove the post title links as well, please advise
December 16, 2016 at 11:45 am #725250Hi,
check out general WordPress tutorials about this: http://www.wpbeginner.com/plugins/how-to-hide-post-and-page-titles-in-wordpress-single-pages/
Best regards,
AndyJanuary 18, 2017 at 12:28 pm #735271Hello,
How can I combine the two codes to remove the link from both pages and blog posts? I am using the child theme.
January 18, 2017 at 11:34 pm #735604Hi,
did you check the Title “Bar Settings” options when editing a page/post? there you can remove any titles.
Best regards,
AndyJanuary 19, 2017 at 11:12 am #735788Hi Andy,
I don’t want to remove the title. Like the original thread; I just want to remove the link from the title. You suggested 2 codes but I am not sure how can I combine them together in the functions.php file. When I added both of them I got an error.
January 20, 2017 at 12:35 pm #736380Hi,
it helps to be very precise with us, so we know exactly what you want.
Use this code inside Quick CSS field:
.post-title.entry-title { pointer-events: none; }
Best regards,
Andy -
AuthorPosts
- You must be logged in to reply to this topic.