Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>1) I fixed pagination simply by implementing <code>&amp;paged='.get_query_var('paged')</code> to my query. Now it looks like this:</p> <pre><code>$hostels = new WP_Query('post_type=page&amp;meta_key=Grad&amp;meta_value='.$grad.'&amp;posts_per_page=60&amp;orderby=title&amp;order=ASC&amp;paged='.get_query_var('paged')); </code></pre> <p>@js1568 i gave him +1 for his answer, but he didnt answer my entire question.</p> <p>Now i can go through pages like so:</p> <pre><code>/acommodation/hostels/?city=beograd - this is page 1 /acommodation/hostels/page/2/?city=beograd - this is page 2 /acommodation/hostels/page/3/?city=beograd - this is page 3 etc... </code></pre> <p>2) The issue with missing info from some pages is fixed by putting this below the end of inner loop:</p> <pre><code>wp_reset_query(); </code></pre> <p>and also i created some custom function which will get all meta values for given post id:</p> <pre><code>function custom_get_meta_values($id){ $first_array = get_post_custom_keys($id); foreach ($first_array as $key =&gt; $value) : $second_array[$value] = get_post_meta($id, $value, FALSE); foreach($second_array as $second_key =&gt; $second_value) : $result[$second_key] = $second_value[0]; endforeach; endforeach; return $result; } </code></pre> <p>In my inner loop i call that function like this:</p> <pre><code>$result = custom_get_meta_values($post-&gt;ID); </code></pre> <p>Then i just echo what i need like so:</p> <pre><code>echo $result['Mail']; </code></pre> <p>Just put the name of meta field in that $result array and echo it.</p> <p>3) I replaced POST with GET request so now i can have links like this:</p> <pre><code>/acommodation/hostels/?city=beograd </code></pre> <p>which when opened will show every hostel from 'beograd'. I only have 4 possible values for cities so if value of 'city' that i capture from GET request is not one of those 4 values, i do nothing, just show that form. If it is i take that value and show the list from that city.</p> <p>As per Will instructions, i will mark this answer as accepted.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload