php - WP_Query: Modify array -


I have managed to integrate a custom taxonomic plugin that:

- employees base What the filter does is select the category.

I want to show it to that department first , and then want to show other departments below the department itself (how it is now) .

Here's the link:

Here's my WordPress Loop:

  & lt; Div class = "staffwrapper" & gt; & Lt ;? Php $ args = array ('post_type' = & gt; 'cripps_staff', 'posts_per_page' => 300); $ Loop = new WP_Query ($ Args); While ($ loop-> is_pause ()): $ loop-> The_post (); Echo & lt; Div class = "col-md-3 spacetop" & gt; '; Echo '& lt; A href = "'. Get_permalink ().' '& Gt;'; echo '& lt; img src ="'; Echo get_post_meta ($ post-> id, 'image', true); Echo '' & gt; '; Echo & lt; / A & gt; '; Echo & lt; H2 class = "staffname" & gt; '; Echo get_post_meta ($ post-> ID, 'staff_name', true); Echo '& lt; / H2 & gt; '; Echo & lt; H2 class = "staffrole" & gt; '; Echo get_post_meta ($ post-> ID, 'staff_role', is true); Echo '& lt; / H2 & gt; '; Echo & lt; H2 class = "staffnumber" & gt; '; Echo get_post_meta ($ post-> ID, 'staff_telephone_number', true); Echo '& lt; / H2 & gt; '; Echo & lt; H2 class = "staffemail" & gt; '; Echo get_post_meta ($ post-> ID, 'staff_email_address', is true); Echo '& lt; / H2 & gt; '; Echo & lt; / Div & gt; '; Endwhile; ? & Gt; & Lt; / Div & gt; & Lt ;! - End of Staff Cover - & gt;  

On the results page (search-people.php) I've added a second WP query using information from this link:

Show it to everyone else For the available post I need an array of $ args2 which: "Show all the posts in a custom post of my staff members"

Here's my attempt:

  // 2 second loop wp_reset_postdata (); $ Args2 = array ('post_type' => 'cripps_staff', 'posts_per_page' =>> '300'); $ Query2 = New WP_Query ($ args2); While ($ query2- & gt; is_paus ()) {$ query2- & gt; Next_post (); Echo & lt; Div class = "col-md-3 spacetop" & gt; '; Echo '& lt; A href = "'. Get_permalink ().' '& Gt;'; echo '& lt; img src ="'; Echo get_post_meta ($ post-> id, 'image', true); Echo '' & gt; '; Echo & lt; / A & gt; '; Echo & lt; H2 class = "staffname" & gt; '; Echo get_post_meta ($ post-> ID, 'staff_name', true); Echo '& lt; / H2 & gt; '; Echo & lt; H2 class = "staffrole" & gt; '; Echo get_post_meta ($ post-> ID, 'staff_role', is true); Echo '& lt; / H2 & gt; '; Echo & lt; H2 class = "staffnumber" & gt; '; Echo get_post_meta ($ post-> ID, 'staff_telephone_number', true); Echo '& lt; / H2 & gt; '; Echo & lt; H2 class = "staffemail" & gt; '; Echo get_post_meta ($ post-> ID, 'staff_email_address', is true); Echo '& lt; / H2 & gt; '; Echo & lt; / Div & gt; '; Wp_reset_postdata (); }  

This is making duplication on my results page, the same post is repeated 6 times! This has taken ages to overcome me, please help: S. should display "all other posts of crapsstaf"

After a few hours of research, I know that this is a double array Adding is like my search-people.php:

  $ args2 = array ('post_type' = & gt; cripps_staff '', 'tax_query' => (array '=' Array ('Classification' = & gt; 'Role', 'Array' ('Classification' = & gt; 'Department', 'Rule' = & gt; Array ('Accounting', 'Corporate')) Field '= & gt;' id ',' rule '= & gt; array (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20), 'operator' => 'IN'));  

But I can not work to organize it correctly for my life, any thoughts? Any wordpress promotional there?

I tried it, it is very close !!! What is this recovering? Array (array '(classification' = & gt; section '' operator '');

I will create 2 questions , for the current department And one for others (excluding the current).

Alternatively, since $ loop is an object that has all the query results, you can remove and remove the existing department

in the codex Of course, you can find all the details on how to filter the query details:

In addition, I suggest that you get_post_meta and instead get_post_custom < / Code>:


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -