wordpress - Group Posts by Category in Monthly Archive -


I am trying to group class posts in a monthly archive, but know how to get it is not.

This is my php I'm using the code archive.php

  & lt ;? Php $ terms = get_terms ("publicationcat"); $ Count = count ($ terms); If ($ count> gt; 0) {foreach (as word $ word) {echo "
A target = \ "_ blank \" href = \ "" .wp_get_attachment_url (get_post_meta ($ post-> id, 'document_file_id', true)). " \ "& Gt; - & gt; POST_TITLE" & lt; / A & gt; & Lt; / Li> ";. Endwhile; echo" & lt; / Ul & gt; "; echo" & lt; / Div & gt; "; echo" & lt; / Div> ";}}? & Gt;

The only problem is to display the same post title for all the conditions.

When you take a loop through the post in each category, then you are not looking for posts related to that category, and instead You are looping through every post

Please note that you can still get some repetition, if one term is more than one category

Please note.

Check each post to ensure that it is in the desired category Good thing - only one query is bad point - every cat For all, write through all the posts.

   is_pos ()):? & Gt; & Lt; Ul & gt; & Lt ;? Php if (in_category ($ word- & gt; slog)):? & Gt; & Lt ;? While Php ($ my_query-> is_psoz ()): $ my_query-> The_post (); ? & Gt; & Lt ;? Php $ link = wp_get_attachment_url (get_post_meta ($ post-> id, 'document_file_id', true)); ? & Gt; & Lt; Li & gt; & Lt; A target = "_ blank" href = "  

Retrieve posts and output that are all caught Good thing - only pulls those posts for which the range is being lost. Bad Points - Many questions can make your site a lot slower.

  & lt ;? Php $ terms = get_terms ('publicationcat'); If (! Empty ($ word)): Forex currency ($ word $ word):? & Gt; & Lt; Div class = "publication-area" & gt; & Lt ;? Php sprintf ('& lt; h3 class = "word-title" & gt;% 1 $ s & lt; / h3 & gt;', $ word- & gt; name); ? & Gt; & Lt; Div class = "publication-txt" & gt; & Lt ;? Php $ args = array ('cat' = & gt; $ word- & gt; word_id); $ My_query = New WP_Query ($ Args); ? & Gt; & Lt; Ul & gt; & Lt ;? Php if ($ my_query-> is_post ()): while ($ my_query-> is_pause ()): $ my_query- & gt; The_post (); ? & Gt; & Lt ;? Php $ link = wp_get_attachment_url (get_post_meta ($ post-> id, 'document_file_id', true)); ? & Gt; & Lt; Li & gt; & Lt; A target = "_ blank" href = "   

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -