get_template_part returns NULL

As the codex page of get_template_part() says: get_template_part doesn’t return a value and doesn’t warn if it fails to find a matching template file. Additionally: If you want to hear about failures, use: <?php assert( “locate_template( array(‘$name-$slug.php’, ‘$name.php’), true, false )” ); ?> So no wonder you are get nothing back. One thing I’m seeing … Read more

How to create a wordpress template without using any page

You may use template_redirect action: add_action( ‘template_redirect’, ‘wpse131387_template_redirect’ ); function wpse131387_template_redirect( ){ if ($_SERVER[‘REQUEST_URI’] == ‘/some-template’) { global $wp_query; $wp_query->is_404 = false; status_header(200); include(dirname(__FILE__) . ‘/some-template.php’); exit(); } }

bloginfo(‘template_directory’) img src

You cannot use bloginfo() while your are outputting using echo because bloginfo it self also out puts string using echo. Below will work for you, you also have extra double quote which i have removed…. <?php $attch_id_1 = pn_get_attachment_id_from_url(get_post_meta($post->ID, ‘img1’, true)); $image_attributes_1 = wp_get_attachment_image_src( $attch_id_1, ‘full’); $attch_id_2 = pn_get_attachment_id_from_url(get_post_meta($post->ID, ‘img2’, true)); $image_attributes_2 = wp_get_attachment_image_src( $attch_id_2, … Read more

Strange Behaviour with is_home()

From look at the code the following logic happens in your case: query is for one post type that has archive is_post_type_archive gets set to true is_archive gets set to true is_home gets set to false since it is seen as archive I am not sure about all implications without extensive testing, but probably approaches … Read more

How to display only an excerpt of the content with custom post types?

You only need two small changes (1st and 3rd lines), though I also took the liberty of tweaking the classes on the div to what seemed more appropriate: <h1 class=”title”><a href=”https://wordpress.stackexchange.com/questions/67750/<?php the_permalink(); ?>”><?php the_title(); ?></a></h1> <div class=”excerpt event”> <?php the_excerpt(); ?> <?php wp_link_pages(array(‘before’ => ‘<div class=”page-link”>’.__(‘Pages’, ‘cpotheme’).’:’, ‘after’ => ‘</div>’)); ?> </div>

Template for slug

Try creating a Page with the users slug, then using a custom Page Template to provide the functionality you want to display all the users.