Customise single.php Part 2

Hello there,

I posted an earlier query about forcing an X global block into single.php.

http://bsuhrecr.nextmp.net/uncategorized/test-post/

We would like to be able to present the page with a large header image like this:

http://bsuhrecr.nextmp.net/staff-benefits/what-we-offer/

Following your advice, I added this code into the child theme’s functions.php file:

function custom_blog_header() {
  if ( is_category() ) {
	echo do_shortcode('[cs_gb id=412]');
  }
}
add_action('x_before_view_integrity__landmark-header', 'custom_blog_header');

Unfortunately, this isn’t displaying, though, and I have double checked the global block’s ID.

Any ideas?

Many thanks,

Spencer

Hello Spencer,

Thanks for reaching out. :slight_smile:

Please change the conditional statement is_category() with is_single(). To learn more, you can take a look at following resource.

https://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page

Thanks.

@Prasant

Thanks for getting back to me - that’s working, thank you.

How would I do the same for the footer with a global block?

Cheers!

Spencer

Hi Spencer,

For the footer, you can add the code below in your child theme’s functions.php file.

function custom_blog_footer() {
  if ( is_single() ) {
	echo do_shortcode('[cs_gb id=412]');
  }
}
add_action('x_before_view_global__footer', 'custom_blog_footer');

For future reference kindly refer to the link below

Thanks

@paul.r

Thanks for getting back to me with this, Paul. Thanks for the customizations link too - I was going to ask you :slightly_smiling_face:

How do I find the hooks for X? For example, I want to add the global block above the colophon.

Regards,

Spencer

Hello @finkk,

Thanks for updating the thread. :slight_smile:

My colleague has shared the link in previous reply. Please take a look at the same. I am sharing over here again.

Thanks.

@Prasant

Thanks for getting back to me - I installed a hook inspector, but cannot see the above mentioned hook - or any others that would allow me to move the global block around the footer.

http://bsuhrecr.nextmp.net/job/senior-it-project-manager-2/

Where can I find these?

Kind regards,

Spencer

Hello Spencer,

If you want to display the global block above the colophon, use this hook: x_before_colophon_begin.

function custom_blog_footer() {
  if ( is_single() ) {
	echo do_shortcode('[cs_gb id=412]');
  }
}
add_action('x_before_colophon_begin', 'custom_blog_footer');

We would loved to know if this has work for you. Thank you.

@RueNel

Thanks for getting back to me. I added that function, but the global block isn’t appearing at all:

http://bsuhrecr.nextmp.net/job/senior-it-project-manager-2/

In my understanding it should appear above the row of icons in the footer. The ID is correct (307), so any idea?

Kind regards,

Spencer

Hello Spencer,

Please use this code instead:

function custom_blog_footer() {
  if ( is_single() ) {
	echo do_shortcode('[cs_gb id=412]');
  }
}
add_action('x_before_view_global__footer-widget-areas', 'custom_blog_footer');

We would loved to know if this has work for you. Thank you.

@RueNel

That’s great and works perfectly - thanks for your help.

Regards,

Spencer

You are most welcome. :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.