Jump to content
Sign in to follow this  
djb21au

How to remove link from title text

Recommended Posts

djb21au

I want to remove the post link from the title text on a post. I know how to do this normally by changing the permalink code in index.php, but can't work out where to find the equivalent in PlatformPro. Assume it has something to do with the pagelines_get_post_title() function, but can't find the actual function. Guidance please.

Share this post


Link to post
Share on other sites
cmunns

You would apply a filter to the function to remove the link output portion of it. but regardless when I look at the function in the core files it shouldn't have a link on the single pages anyway.

Share this post


Link to post
Share on other sites
djb21au

Thanks Adam. I actually want to remove the link from the blog page, not the single posts, as the blog page version is exactly the same as the single post (it's a photo blog). Can you give me a hint as to the filter I would need ??“ or at least how I target the piece of code to filter out?

Share this post


Link to post
Share on other sites
cmunns

Well here is the function ` function pagelines_get_post_title( $format = '' ){ if ( is_singular() ) { $title = sprintf( '

%s

', apply_filters( 'pagelines_post_title_text', get_the_title() ) ); } elseif( $format == 'clip'){ $title = sprintf( '

%s

', get_permalink(), the_title_attribute('echo=0'), apply_filters( 'pagelines_post_title_text', get_the_title() ) ); } else { $title = sprintf( '

%s

', get_permalink(), the_title_attribute('echo=0'), apply_filters( 'pagelines_post_title_text', get_the_title() ) ); } echo apply_filters('pagelines_post_title_output', $title) . "n"; } ` you see the filter there at the end to use? Do you know how to use filters?

Share this post


Link to post
Share on other sites
djb21au

No, but I'm happy to learn if you can point me to a good resource. I have used hooks so understand the general idea.

Share this post


Link to post
Share on other sites
bryan-hadaway

Please wait for further help from Adam. Thanks, Bryan

Share this post


Link to post
Share on other sites
djb21au

Thanks. That article was pretty good. I've had a play but I'm missing something (this will demonstrate my limited knowledge). I've added the following code to functions.php:

	function pagelines_post_title_nolink()
	{?>
		{$title = sprintf( '<h2 class="entry-title">%s</h2>', apply_filters( 'pagelines_post_title_text', get_the_title() ) ;}
	
		echo apply_filters('pagelines_post_title_nolink', $title) . "n";
	<?php }
	
	add_filter('pagelines_post_title_output','pagelines_post_title_nolink');
	

I've tried a few things but whatever I put into the function just gets returned literally (see www.streetsofmytown.net to see what I mean) I also tried just using a div within the function (as per the example on the tutorial) but it just comes back blank ??“ I'm not sure how to define and call the 'post title' variable.

Share this post


Link to post
Share on other sites
bryan-hadaway

Please await further developer help. Thanks, Bryan

Share this post


Link to post
Share on other sites
djb21au

I've managed to find something that works, though I don't know if it is the most efficient approach: ` function pagelines_post_title_nolink() { $titlenl = get_the_title(); return $titlenl; } add_filter('pagelines_post_title_output','pagelines_post_title_nolink'); ` If there's a better way I'd be happy to be told.

Share this post


Link to post
Share on other sites
djb21au

A problem I've noticed with my solution above is that there doesn't seem to be a class applied to the returned text, so I can't change its format. EDIT: Found the class: post-title

Share this post


Link to post
Share on other sites
Simon

Always better to use built in filters. `add_filter ( 'pagelines_post_title_output', 'wp_strip_all_tags');` And one liners are cool ;)

Share this post


Link to post
Share on other sites
djb21au

Thanks Simon - an elegant solution. I browsed numerous WP forums and no-one mentioned that wp function.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×