-1

I am writing a plugin where I need to display the post data inside the loop using the theme content template in a page. It will be a similar page to the author profile page that displays a list of posts but with my own wp_query. I am currently using the following code-

while( $wp_query->have_posts() ) : $wp_query->the_post();
        get_template_part( 'content', get_post_format() );
endwhile;

but the problem is this works for some theme and some not. In some theme they don't output anything. Is there any way so I can make it work on all theme or at least maximum theme?

  • 1
    Every theme is different, - there is no standard way of naming (or even using) a template part. You would be better off using your own markup and default styles, but allow theme authors to override it with hooks & filters. – TheDeadMedic Sep 5 '16 at 10:38
  • Agreed with TheDeadMedic's comment above. Highly depends on how the author of the theme has built it. – EBennett Sep 5 '16 at 12:26
  • @TheDeadMedic as an answer please :) – Rarst Sep 5 '16 at 16:44
0

Every theme is different - there is no standard way of naming (or even using) a template part. You would be better off using your own markup and default styles, but allow theme authors to override it with hooks & filters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.