How to get Category selection to resolve to Directory Page Template?

[ad_1]

Hi Steven,

Actual I just found a function snippet that worked which you provided a few years ago for another website we worked on, that had the same need. 🙂

Thanks!
Mitch

Plugin Author
Steven

(@shazahm1hotmailcom)

Good to hear you found the solution! I do have to apologize!!! It seems to have missed your reply to the other support forum thread. It this the same issue?

Hi Steven,

Yes, it actually was the same issue. 🙂 It just hit me that you had helped us with the same issue a few years ago, so luckily I found the snippet code needed.

Thanks again! 🙂
Mitch

Plugin Author
Steven

(@shazahm1hotmailcom)

ok, I’ll mark both resolved.

If I may… can you share the code snippet, so I can refresh my memory. Thanks and have a great evening.

Hi Steven,

Not a problem. Here is that snippet.

Connections :: Load Template Based on Entry Type

add_filter(
	'cn_load_template',
	function( $atts ) {

		if ( $slug = cnQuery::getVar( 'cn-entry-slug' ) ) {

			// Grab an instance of the Connections object.
			$instance = Connections_Directory();

			$result = $instance->retrieve->entry( $slug );

			if ( false !== $result ) {
				$atts['list_type'] = $result->entry_type;
			}
		}

		return $atts;
	}
);

This basically allowed the Directory to use a different page template than the profile page template without having to use “home_id” for the shortcode on the Directory page. The profile page template is then able to utilize the “Individual” template type we chose in the template settings, without having to use the “home_id” for the Directory shortcode. So as a result we can use the category, keyword search, alpha filter, etc., on the Directory page and have that resolve using the Directory page template, instead of the “home_id” template of the profile page as it was trying to do previously. If that makes sense. 🙂

Thanks!
Mitch

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer