Join our new community forum for support & discussion

Join Now

Home Support Themes ExpertHive filter in functions.php to apply only in Listing page

filter in functions.php to apply only in Listing page

  • Author
    Posts
  • Alf

    Hello,

    How can I add a filter or an “if” in the functions.php, so the code inside only applies to the listing pages, not to the Listings List, nor home nor other pages?

    Thank you.

    A.S.

    ihor developer

    Please try using this one:

    add_action(
    	'template_redirect',
    	function() {
    		if ( ! is_singular( 'hp_listing' ) ) {
    			return;
    		}
    
    		// custom code here.
    	}
    );
    Alf

    Thank you. This works just fine.

    However, I am using the code from the link below to show the Attributes as a bullet list in the Listing page (Primary), which looks great and I am using this filter to keep them in one line in the Services page (Block – Secondary). With this code, it works great.

    However, the Related Listings inside the Listing page keep using the bullet list style. Is there a way to specify that the code only applies to the Attributes in Page-Primary and not to the Block-Secondary?

    link: https://hivepress.io/support/topic/attributes-fomat-spacing-and-line-jumping/#post-13156

    Thank you very much.

    Alf

    Disregard my previous question, it seems to work well now.

Viewing 4 posts - 1 through 4 (of 4 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.