Use one template only for custom post type archives?

add_filter( ‘template_include’, ‘wpsites_cpt_archive_page_template’, 99 ); function wpsites_cpt_archive_page_template( $template ) { if ( is_post_type_archive() ) { $new_template = locate_template( array( ‘your-cpt-template.php’ ) ); if ( ” != $new_template ) { return $new_template ; } } return $template; } Try this in your functions file. You can add your post types to this line like this: if … Read more

Different templates for same content, landing page from different URLs (generic, simple)

I don’t know what your definition of “simple” is, so not sure this qualifies. It’s not really a simple task to do this dynamically. First, we register a new query var to pass the alternate identifier: function wpd_portfolios_query_var($query_vars){ $query_vars[] = ‘portfolio_key’; return $query_vars; } add_filter(‘query_vars’, ‘wpd_portfolios_query_var’); Next, we add a rewrite rule to handle incoming … Read more

wordpress use single ajax in place of multiple ajax requests in a smarter way

I appreciate your question is quite old and you no doubt already have your solution but hopefully this may help someone else. You could replace your javascript post calls with a single call to a single function that extracted both parts of data and returned them as an object. $(‘body’).on(‘change’,’#product_name’, function() { //Get product prices … Read more

How to get link to homepage

echo esc_url( home_url( “https://wordpress.stackexchange.com/” ) ); this best practice. get_bloginfo( $show, $filter ); It has lots of Parameters to get info so let see the ##SHOW(Parameters): name,description,wpurl,url,admin_email,charset,version,html_type,text_direction,language,stylesheet_url,stylesheet_directory,template_url,pingback_url,atom_url,rdf_url,rss_url,rss2_url,comments_atom_url,comments_rss2_url,siteurl,home so if you want to use this finction you have to use like get_bloginfo(‘wpurl’); or get_bloginfo(‘url’); These two functions home_url() and site_url() return the same value (WordPress address … Read more