Set up The Loop with query parameters. This will override the current WordPress Loop and shouldn’t be used more than once. This must not be used within the WordPress Loop.

learn more… | top users | synonyms

0
votes
0answers
18 views

query_posts with sorting on a custom datestamp

I have a custom meta field that I want to use to sort with query_posts but its not ordering my posts properly since it is a datestamp (i.e. 04/21/2014) and its treating it like a normal text string. ...
0
votes
1answer
17 views

Problem with single-page for my custom post

I'm working on a website with a portfolio section, and I'm almost finished with this section, but I have a problem with the single page which is : whenever i click on any portfolio link, the single ...
2
votes
0answers
56 views

Display a query with multiple post types and same relationship on a single page

I am creating a client portal were my clients can maintain their projects and leave feedback in Wordpress. I have two custom post types called "Clients" and "Projects" and they each pull information ...
0
votes
1answer
22 views

Order post type by sum of two custom fields

I have a custom post type for vouchers. I've added two custom fields to this post type named "value_1" and "value_2". They both contain a number. (The first value will be applied at checkout, the ...
0
votes
1answer
22 views

Display specific posts on home page

Can someone please help me figure out if the "List category posts" plugin is the easiest solution to my problem: My goal is to be able to choose which posts are displayed on our homepage under ...
0
votes
1answer
16 views

Remove duplicated posts in the loop if post has more then one categorie

I have some posts with more then one categorie. In the post loop i get the post based on the selected categorie by the user. If the user select 2 categories where one post is assigned to, the loop ...
0
votes
0answers
10 views

Can display previous post with or without wp_pagenavi

I use Wordpress with the free version of Pageline platform theme. I figured out that the "previous/next entries" links are displayed on the main page but not on my others static pages. I tried to use ...
1
vote
1answer
21 views

How to query_post custom posts within default taxonomy?

I'm trying to query_post custom posts. It works very good with custom taxonomy, but not with default "category" taxonomy. I tried using "category_name" and "tax_query", but it doesn't work for me. ...
1
vote
1answer
27 views

get_the_title($postID) OR get_the_title()?

I would like to know which could be more performant between these two approaches of getting data of a post To use a loop after a WP_Query($aConditions) and use functions like get_the_title() ... and ...
1
vote
1answer
14 views

How to display posts by vote count and if no value continue with latest posts with no votes?

Maybe someone can help me with this. I want to display posts by votes. Users can only vote up. So what I want is - the most voted posts by vote count on top and then latest posts with no votes. The ...
1
vote
2answers
37 views

Different Ways to Query Custom Post Types?

I'm using this code to use custom post types like regular post: add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); function add_my_post_types_to_query( $query ) { if ( is_home() && ...
-1
votes
0answers
15 views

Suggested posts from categories

I need a certain procedure to display suggested/similar posts for each post, but I've never done something like this, so I'd ask for some guidance: Take all the categories the current post belongs ...
0
votes
0answers
61 views

Pagination not working on template page

I have the following code, but it is not working. if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = ...
0
votes
1answer
105 views

How to pass multiple checkbox values to wordpress query?

I am working on a website that has multiple check boxes and I want to show results based on what user has selected. There are about 16 check boxes for music, 8 check boxes for venues and 6 radio ...
0
votes
1answer
28 views

Remove Post if Advanced Custom Field is checked to fix paging

I'm trying to setup a query that filters through posts and removes ones that have an ACF field "archived" checked. Post queries are pretty foreign to me. ...
0
votes
2answers
57 views

How to echo the_title from an array of posts?

I'm trying to query wordpress post by using query_posts and trying to save them in an array so that I get retrieve the post from array. This is what I'm doing, $posts =array(); $args = ...
1
vote
1answer
29 views

How To Get Posts With A Specific Word

How to retrieve posts with a specific word in the loop. For example, I want to retrieve all posts with the title of the profile post (custom post type): ...
0
votes
0answers
23 views

Global post is always custom post type last post

my global $post is always taking the object of my custom post type "advertisement". So when i'm editing e.g. "Hello world" which post id is 1, it shows me post id of the last advertisement post. If ...
0
votes
0answers
38 views

Polylang fallback language does not get activated even with patch

<?php //my patched archive.php to display posts of a category get_header(); ?> <div id="content"> <?php global $wp_query; ...
0
votes
3answers
94 views

Custom Query With Multiple Meta Key Value

I am new with WordPress development and I have found this query and I want pass multiple key and value in this query. My Query is: $querydetails = " SELECT wposts.* FROM $wpdb->posts ...
0
votes
1answer
18 views

Ordering custom post type by custom field without a title

My custom posts don't have a title, rather they rely on custom fields, and all the solutions I've tried so far seem to work if the title is present. <?php $paged = (get_query_var('paged')) ? ...
0
votes
1answer
43 views

WP MS: How to query over the network

I have a WP 3.8.1 Multisite installation with 3 blogs, they're all in one db, prefixed wp_, wp_2_ and wp_3_. In a template in wp_ I try to to display all posts from wp_, wp_2_ and wp_3_ which have a ...
0
votes
3answers
104 views

ACF: post query, hide duplicate values

I'm querying an ACF field, and displaying all the results on the front-end like so— PHP: <ul class="category-menu-items"> <?php // args ...
0
votes
2answers
62 views

How to display a number of posts based on a Advanced Custom Field (ACF)

I have the following code working fine in my theme: <!-- Modify query object --> <?php query_posts('showposts=5&post_type=news'); ?> <!-- Start the Loop --> <?php if ( ...
0
votes
1answer
33 views

query post based on comparison

Each post in my site can be rated as 'good' , 'ok' , 'bad'. The values are stored in custom fields. I now need to show top 10 posts with maximum 'good' and it should not display posts with greater ...
0
votes
1answer
59 views

Custom post type blog pagination conflict

I have a custom post type called 'emp_case-studies' and it has a page archive. Here is the code for archive-emp_case-studies.php: <?php $blog = $wp_query; $wp_query= null; $args= null; ...
1
vote
1answer
23 views

Query a WordPress page by its title (which has a parent page)

I have created a wordpress query which takes the entire content from 1 particular page using the its title So far i have the following: <?php query_posts('pagename=features'); if (have_posts()) : ...
0
votes
0answers
58 views

Post per page not working

I have 2 parent categories are app and game. Beside them has child categories. My code get 6 post from 2 parent categories with orderby post date and order DESC, but post per page not working. Please ...
0
votes
1answer
69 views

Make query_post category name dynamic

I have a working funtion: <?php query_posts('category_name=category');?> I want to make the category name dynamic to reflect the page title. Something like this: <?php ...
0
votes
2answers
37 views

number of posts per page + random + exclude categories

I have the following code in my home.php <?php query_posts($query_string . '&orderby=rand' . '&cat=-182,-184'); ?> query_posts seems not the best solution. What would be the best way ...
0
votes
2answers
35 views

Display trimmed version of the_post()

I am using the following code to display pages on one page and would like to trim the content of each page on this display to 50 words and include images that are attached to the page. How do I go ...
-1
votes
1answer
68 views

Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work

I am using ACF as related posts. I have the following code. <?php $post_objects = get_field('repeater_related_items'); if( $post_objects ): ?> <ul> <?php foreach( $post_objects ...
0
votes
0answers
20 views

Query Posts oder by Date

my query does not work as it should. This is my Code: wp_reset_query(); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'post', ...
0
votes
1answer
51 views

How can I list custom post by custom category?

From some references I wrote a code for create custom post type (journal) and taxonomy using following code. It works fine. Next I am add a new category from admin side for my custom post type ...
0
votes
2answers
46 views

Show previous month's posts

I've managed to loop through the current month's posts in January but I am trying to get the previous month's posts in December of the previous year. I think this is where the problem might be, that ...
1
vote
1answer
67 views

Wordpress Custom Query to show posts from last x years

I have found a way to show all posts from the current year with this code: <?php $today = getdate(); $lastyear = $today[ 'year' ]; $args = array( //'nopaging' => true, 'paged' => ...
0
votes
1answer
96 views

Multiple templates for custom post type

This is my setup: I have one post type called "products" and a page (page X) where I use wp_query to list all products, the_permalink(); returns the link to single-products.php. The goal is to use ...
0
votes
2answers
94 views

WordPress /page/2 not working

When clicking the next_posts_link it just shows the same posts as on page 1. It appears to work fine on the category pages and it is only affecting the homepage (home.php) Thanks! <?php ...
0
votes
1answer
41 views

get post excerpt by query

I'm trying to get post excerpt by query my code is below global $wpdb; $posts = $wpdb->get_results ("SELECT post_title, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' AND ...
0
votes
1answer
32 views

specific post is not excluded from the loop

I have registered a CPT and created archive-myCPT.php, here I want to exclude a specific post from the main loop. This is my code: <?php $query = new WP_Query( array( 'post_type' => ...
2
votes
0answers
54 views

WordPress query for most recent posts from multiple categories

I have 5 categories. I want to query each category and get a list of the most recent posts from them. I also only want single post from each category, with no duplicates. Is there a way to do this ...
0
votes
0answers
133 views

Display newest posts from multiple categories ordered by date

I have the categories listed below in my post post type. Category Name: Test 1 ID: 1 Category Name: Test 2 ID: 2 Category Name: Test 3 ID: 3 Category Name: Test 4 ID: 4 I'd like to retrieve for ...
0
votes
2answers
43 views

WP Query - Is this correct?

Trying to debug, getting headache so I want to ensure that I have placed the query args in the correct place. I want to sort/order all my posts based on "myvalue". <?php if ( ...
0
votes
1answer
30 views

How can I list posts with different formats depending on order?

Let's say I have a regular main page listing posts, like in any regular WP blog. Now, I'd like to achieve this: if it's the first post in the list, use some layout, if second, another layout, if ...
0
votes
0answers
83 views

url_to_postid redirected posts

i wanna url_to_postid some urls, it work pretty fine but when it come to auto-redirected posts it fail to return postid. here is my example urls: http://animup.net/anime/kuroko-no-basket-2/ auto ...
0
votes
1answer
24 views

Adding a category at even positions on main loop with modified pagination

I have different categories showing over main loop. I want to add a specific category post at even positions of main loop. Example current post list with categories: cat1 cat1 cat1 cat1 required: cat1 ...
0
votes
0answers
94 views

why is pre_get_posts not working

function include_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '3' ); } } add_action( 'pre_get_posts', 'include_category' ); I ...
0
votes
1answer
28 views

Query counting excluded category on paged loop

I have an Index.php with a basic loop with this query before: <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'category_name' => 'work', ...
0
votes
1answer
71 views

query_posts orderby postmeta

I'm trying to retrieve a custom post type and order it by a custom date stored in postmeta. The custom date is a unix timestamp. The meta_query works correctly - it only retrieves posts with a ...
0
votes
3answers
44 views

How would I get 1 latest post from a query for 5 posts?

So I have a wp_query which is getting the 5 most recent posts from my Wordpress site. What I want to do is from within this query, grab the most recent post and show this as a sort of 'hero' post, and ...