Show full post on specific category page only

Hi there,

I’m setting up a second blog on my page, which I’ve done by linking to a specific category in my menu. On this category page only I would like show full post content and have found this snippet, which should solve the problem:

if ( ! is_category('Release notes') )
	return $bool;//<= if current context is not home
				//then use the global option set in Appearance > Customize > Pages & Posts layout
return false;//<= else set to false to display the full post content

}

However, I cannot make it work, can you help me?

Also, I would like to disable the post links on this category page as well (as the full post is visible it is obviously not needed).

Thanks in advance.

I just saw, that my code is behaving oddly when pasting it here, so here is a screen shot of the full snippet.

Hi There,

There’s recent post element available, though this element by default doesn’t show excerpt/full post content. It might be possible to customize shortcode.

Or else, if you’re not familiar with coding you may try a third part plugin for example (https://wordpress.org/plugins/ultimate-posts-widget/) and see if that suits your needs.

Thanks!

Hi mldarshana,

Thanks for your reply.

I’m still learning, so I’m not an expert in coding. However, I do prefer to solve this problem with a filter or function in my child thems functions.php file, as I’ve learned it is possible. I’m just struggling making the snippet work…

Any suggestions on how to make it work without installing a plugin would be much appreciated!

Hi there,

This falls into custom development as this is feature is not native to the theme so we can’t really provide you with the exact code that you need.

But based on the current code that you have, I am not certain where you added it.

What I can suggest is that you could create a template in the child theme that targets the specific post category page.

To do this, you will have to override the file _content.php that is in \x\framework\views\global,

Copy the file from the parent theme and place it in the same directory of the child theme then the file content should be like this:

<?php

// =============================================================================
// VIEWS/GLOBAL/_CONTENT.PHP
// -----------------------------------------------------------------------------
// Display of the_excerpt() or the_content() for various entries.
// =============================================================================

$stack                     = x_get_stack();
$is_full_post_content_blog = is_home() && x_get_option( 'x_blog_enable_full_post_content' ) == '1';

?>

<?php

if ( is_singular() || $is_full_post_content_blog ) :
  x_get_view( 'global', '_content', 'the-content' );
  if ( $stack == 'renew' ) :
    x_get_view( 'renew', '_content', 'post-footer' );
  endif;
elseif ( in_category('audio')) :
  x_get_view( 'global', '_content', 'the-content' );
else :
  x_get_view( 'global', '_content', 'the-excerpt' );
endif;

?>

Notice the lines:

elseif ( in_category('audio')) :
  x_get_view( 'global', '_content', 'the-content' );
else :

That is added to the code to check if the category of the post category slug is audio and if it is, it will use the file that is in \framework\views\global_content-the-content.php which displays the entire content of the post instead of \framework\views\global_content-the-excerpt.php that only displays the excerpt of the post.

Hope this gets you started.

Hi Jade,

Thanks for your reply and your suggestion.

As I wrote, I would prefer to solve this customization using a function or filter in the functions.php file of my child theme. So is it possible that you instead could provide me with at filter og or a function snippet to do the same as you have suggested? I would rather not do customizations by overriding templates.

Best regards.

Hi there,

Unfortunately, not everything could be altered using filters just like this case because the index template for X is structured using the theme files with some conditions in the code on what will display to what stack.

For now this is only the ideal solution we could provide to achieve what you are trying to do using X.

Thank you.

Hi Jade,

Thanks for your reply. I’ve tried to copy the _content.php file to my child theme directory and added your code. It does not seem to have an effect, though.

This is my second blog page, on which I would like the full post content to show - as it looks like, when you click the link on the post. Any suggestions on, what I am doing wrong?

Hello There,

Could you please post the contents of your _content.php file? And by the way, if you want to display all the posts under the releasenotes category, you should also have this block:

elseif ( in_category('releasenotes')) :
  x_get_view( 'global', '_content', 'the-content' );
else : 

Please let us know how it goes.

Hi RuelNel,

The content of my _content.php file is already in this topic, as I followed the guide provided by your colleague.

Thanks for the adjusted code! Now the content of the full post is showing, however, what I really need is to show the post as it is displayed when clicked on the heading, please see attached image.

How do I achieve this?

Hi there,

You mean display the full content instead of excerpt? Please replace this line

if ( is_singular() || $is_full_post_content_blog ) :

with this

if ( is_singular() || $is_full_post_content_blog || is_category('releasenotes') ) :

It’s is and not in since we’re dealing with the category page.

Thanks!

Hi Rad,

Thanks for your reply. Yes, I want to show the full content and not the excerpt and also I want to disable the entry title links, as they are obviously not needed then.

So now I’ve adjusted my content to this, but it’s still not working. Maybe I got confused by your different suggestions for customizations.

Thanks!

Hi There,

Would you mind providing us with login credentials(by clicking on the Secure Note button at the bottom) so we can take a closer look? To do this, you can make a post with the following info:

  • Link login to your site
  • WordPress Admin username / password
  • FTP credentials

Thanks.

Hi Thai

Thanks for your reply. Sure, I will make a secure note with the requested info.

Hi There,

The _content.php file should be under pro-child/framework/views/global directory.

I’ve already corrected it for you.

The full post content is showing on the releasenotes category: https://frametest.knowledgeworker.dk/category/releasenotes/.

That is technically possible. However, that would fall beyond the scope of our support since it would require custom development.

Thank you for understanding.

Thanks for the help!

I don’t really understand the last part about custom development, as the post already is showing as I requested, so it’s great.

Can you help me disable the entry links on post in this category as well?

Hi there,

Although you have the title and the content displaying now, what you are trying to do still falls under custom development because you will have to write some custom Javascript and some more CSS to have the content slide down or show up as you click on the post title.

Please try this code in the global CSS

.category-releasenotes .entry-title a {
    pointer-events: none;
}

Hope this helps.

Hi Jade

Oh I see… But I’ve achieved the result that I wanted so don’t worry about it.

The CSS worked perfectly, thank you so much for your help. It’s much appreciated!

On behalf of my colleague, you’re welcome. Cheers! :slight_smile:

Hi there,

now I seem to have another problem with my blogs - the header (blog/category title and description) is suddenly missing. I tried to follow guides in the support forum, however I can’t seem to locate where to enable it again. Any suggestions on how to get them back?

Thanks!