A generic term referring to the process of retrieving information from a database.
1
vote
1answer
233 views
mysql query from wordpress page using custom table
I want to a mysql query that matches a page title. Not sure of a better way to accomplish this task, but I am stuck.
This is my basic test code.
<?php
$page_title = wp_title('');
echo ...
0
votes
1answer
141 views
Adjust the order for returned posts
I have written a neat responsive slider for my Wordpress featured articles (feel free to use it):
<?php
$responsive = 'on' != get_option('henrik_responsive_layout') ? false : true;
...
0
votes
1answer
134 views
Export all posts to import as product items
Up until now, my client has been using WordPress posts as his way to display his products. I now need to export all these posts into a CSV format so that I can format the CSV file and import it back ...
-3
votes
2answers
532 views
How to execute SQL SELECT query and see the results?
I want to run a SELECT query on the Wordpress database and get the results on the screen.
Any widget which does it?
2
votes
2answers
196 views
Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
I have a custom post type 'events', to which I have associated a custom taxonomy 'calendar'. The calendar has 12 fixed terms, for each month of the year ( 'august', 'october', 'november, etc.).
I'm ...
0
votes
1answer
507 views
$wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?
I have a custom post type 'event', a custom meta field 'event_date' and a custom taxonomy 'locations'.
I want to query $wpdb to retrieve posts in this way
posts must be of the 'event' post type
...
1
vote
1answer
60 views
Most liked page not displaying posts
I was looking for a post rating system for a while, then I stumbled across a great tutorial:
http://wp.tutsplus.com/tutorials/how-to-create-a-simple-post-rating-system-with-wordpress-and-jquery/
I ...
0
votes
1answer
91 views
wp_list_pages() refuses to output posts
Someone help me understand why the following do not output anything:
wp_list_pages( 'post_type=post' )
wp_list_pages( 'post_type=event' )
Yet the following work as expected:
wp_list_pages( ...
0
votes
2answers
53 views
Access Tables with number prefix
I have multiple sites setup within my site. I need to access all the various options tables which are named 'wp_#_options'. How can I select these tables that have a number prefix?
Using
...
0
votes
1answer
127 views
Start Query from 2nd Post without offset
is there a quick and easy way to load all the posts, starting with the second post and making the first post the last post? If I use offset, I then lose the first post, but I don't want to lose it, I ...
1
vote
1answer
56 views
Limits, not all post are showen when querying for posts by view count
I'm having some difficulty getting a loop that gives me post by most viewed.
I started by following this tutorial
...
0
votes
1answer
966 views
Get the number of rows from $wpdb->get_results not working
I want to count the number of rows of this custom wordpress query and it does not work:
*PS I am accessing a custom table inside my wordpress database, mabe by myself. The $wpdb->get_results part ...
1
vote
1answer
347 views
Is there any need to use both wp_reset_postdata and wp_reset_query together?
Is there any need to use both wp_reset_postdata() and wp_reset_query() together?
Is it a case that I would pick one of the two functions; is there any point in doing this after a query :
...
2
votes
1answer
705 views
WP_Query vs get_posts
I have read a number of questions on SE regarding these but I still can't figure the exact difference wrt usage. Would it be true to say that I would probably use WP_Query for the majority of ...
0
votes
1answer
94 views
List author's posts with SQL
I want display authors'posts with the code below but authors' name aren't showing.
What is wrong?
<? // query test
$qry = $wpdb->get_results( $wpdb->prepare("
SELECT *
FROM $wpdb->posts
...
1
vote
1answer
77 views
Query Page Content From Theme Options?
I'm trying to create a slider where you choose what pages are shown in the slider, using a theme options panel based on the https://github.com/vauvarin/options-framework-theme
That lists the pages in ...
0
votes
1answer
186 views
Query Posts with MetaValue & MetaKey & SortOrder works, but it doesn't override category order [closed]
I have a query, ordered correctly by the meta_key in ascending order, but they are devided into groups of their category.
This example shows the postorder in the WP category editor:
Cat 6
- sub 1
- - ...
1
vote
1answer
91 views
posts_per_page option limits the number of Gallery items
I have noticed that if I have a query where posts_per_page are set to 4, any (image) gallery that belongs to one of those posts will too have only 4 items (although when I create the gallery from Add ...
0
votes
2answers
222 views
Exclude some authors from query
This script list users with their last post. How to exclude some authors from guery ?
<?php
//List of users sorted descending by date of lastest post written by user
$uc=array();
...
1
vote
0answers
58 views
Why orderbyb meta_value_num won't affect the generated SQL Query order?
I've exhausted myself with this and I couldn't figure out why when I do this
$myposts = new WP_Query( array('numberposts' => 5,
'offset' => '0',
'post_type' => 'noticias',
'orderby' => ...
0
votes
3answers
282 views
Split wordpress loop to multiple layouts
OK so I've searched a lot and couldn't find a straight forward answer to my question.
I am simply trying to use one category loop that will display posts in a category page in a wordpress site. lets ...
0
votes
1answer
408 views
Display posts with a start OR end date later than current date
I'm working with an upcoming events list. I create a custom post type, with a custom field: [event_start_date]. I also have some multiday extension events, defined by an additional custom field: ...
0
votes
1answer
79 views
Query does not return content
Working on updating an old WP site developed for WordPress 2.0 and have a post (page) query that does not return the "post_content" data.
Here is said query:
$the_query = ...
1
vote
2answers
83 views
How to organise this data within WordPress
I have a dilemma in how the data in this scenario should be organised, as well as queried.
The main elements in the scenario are the following:
Competition
Team
Player
Each player plays for one ...
0
votes
2answers
183 views
Duplicate posts
I'm currently working on a Magazine style website and on the main page I have three different sections where I display the latest news. Slider, latest news and more news.
The problem is I can't ...
0
votes
2answers
124 views
get last post's link with SQL query
I have installed a WP on website A and I want the last post's links in site B.
I haven't in site B any WP and I want to get the link of last post from website A.
so I can't use WP API like WP_Query ...
2
votes
1answer
220 views
Adding posts of custom type into the main feed
I'm having some trouble with a subject that seems to be pretty basic, so I'm starting to feel (a little, only a little) dumb :-)
Here's the thing: I want my main feed to include the posts and other ...
2
votes
1answer
35 views
How do I query for a post by custom field?
I have a custom field called "song-id" and I'd like to lookup a post by a song-id value. Can someone give me the code snippet for it?
(bonus: also looking for a code to use the permalink in the post ...
1
vote
0answers
58 views
Dynamically adjust single-posttype.php query, based on current taxonomies
I have a single-teamphoto.php template loading data from a Team Photo - Custom Post Type, showing team photos with team member names below, one photo at a time, with a navigation list of available ...
1
vote
0answers
70 views
category pagination got broken suddenly
i need some help here please!
The pagination just stopped working suddenly with the default post type and default wp query, with plugin "wp-paginate" or even with next/prev arrows!
It echo 404 error ...
1
vote
0answers
179 views
Exclude posts with taxonomy term from appearing on home page query
I am really confused about this one, I am usually pretty good at working out basic queries but I can't seem to work this one out.
Please see below my index.php query. Now it is not your basic query ...
0
votes
2answers
316 views
How to modify the query to exclude posts by slug?
How can I modify my query in order to exclude certain posts by slug?
Is it possible?
query_posts(array('category_name' => 'Mycat', 'posts_per_page' => -1));
Ty
1
vote
1answer
221 views
Display category posts grouped by taxonomy
I'm working on a project where I use the default posts as "Products", default category as "Application" and a custom taxonomy called "Groups".
I want to list "Products" by "Application" ...
0
votes
2answers
190 views
shortcode using multiple WP_Query's with multiple category names not fully functional
we're working on a bilingual site,
Larry A. Downs
all the posts are categorized into two categories, english or spanish, along with other categories. so every post has multiple categories,
i've ...
0
votes
2answers
125 views
Transient api Caches confused
This code works for page 1
<?php
$paged1 = (get_query_var('paged')) ? get_query_var('paged') : 1;
$recent1 = get_transient( 'recent1' );
if ...
1
vote
1answer
494 views
Use get_post_types to query only custom posts types
I need to query only custom posts types - that is all post types in my WP install excluding posts and pages. I have used get_post_types to build a string of all custom post types which I want to ...
0
votes
1answer
102 views
Pagination in wp query with transient api
I have intergrated wordpress transient system with w3 total cache. Now i can`t to do pagination for this query.
<?php
$paged1 = ...
0
votes
1answer
86 views
Query post & loop problem.
i having trouble while i added query to loop.
please have a look whats the problem.
here is the link
<div class="fl" id="main_article">
<?php $count = 1;
$the_query = new WP_Query( ...
4
votes
2answers
264 views
How to display Section for certain time
i am building a News site. I want to display 1 featured post from "prime" category for only few hours. after it should be expired or disappeared from the section.
please have a look here u can see ...
0
votes
1answer
108 views
Conditional category query breaking?
In my loop.php (see below) I basically have a condition where if the page is not paginated (i.e. if the URL does not look something like this: example.com/page/2) then display 2 posts with a category ...
1
vote
1answer
76 views
Sort query by author: 1 author, then others
I have a post type called 'article' and on the article archive page i'd like to show all the articles, sorted by author.
function kia_adjust_the_query( $query ) {
// change posts_per_page ...
3
votes
2answers
503 views
Sort custom post type list table by display name of a user id stored as post meta value
I have a custom post type named domicile. Each post (domicile) has an owner (not the author). Owners are users with a custom role. I store the user id as a post meta value (dmb_owner) for the domicile ...
0
votes
1answer
149 views
Pull post meta with post_query?
I'm building a custom index loop that just uses query_posts at the moment.
The issue is that inside The Loop, I have to then query for the post meta data (with get_post_meta), which I believe has ...
0
votes
1answer
164 views
show posts only on homepage but using custom post type and taxonomy for query posts via url
I would like to do the following:
I have a index.php file in which I query all posts from the existing post_types. Like the code below.
<?php if (is_home()); { ?>
<?php
global ...
0
votes
1answer
231 views
Show only, when taxonomy has posts?
I'd like to query posts by taxonomy like this:
<?php
global $post;
$terms = get_the_terms( $post->ID , 'movies', 'string');
$do_not_duplicate[] = $post->ID;
if(!empty($terms)){
foreach ...
0
votes
1answer
640 views
$wpdb->get_var not returning a result
I launched mysql and confirmed this query returns a result:
mysql> SELECT * FROM wp_posts WHERE post_parent = 68 AND post_type = 'attachment' AND post_name = 'side-logo-auto2' LIMIT 1;
1 row in ...
5
votes
5answers
686 views
How can I make wp-pagenavi work on a custom query built upon a form submission?
I've also posted this on the wordpress support forums, for scribu's wp-pagenavi plugin:
http://wordpress.org/support/topic/plugin-wp-pagenavi-custom-query-form-submit-part-2?replies=1
My situation:
...
0
votes
1answer
833 views
Query Posts By Post Publish Date, but sort by Custom Meta Key
I'm trying to show the most popular (recent) posts on my blog. I have made a special formula for this. I am querying for these posts like so:
$args = array(
'post_type' => 'post',
...
0
votes
2answers
1k views
Custom $wpdb Query for Custom Post Type by Category
I am using the following code to output a list of items in my 'documents' Custom Post type by Year and Month.
<ul>
<?php
$post_type = 'documents';
global $wpdb;
/**/
$years = ...
1
vote
3answers
1k views
$query->query_var['post_type'] not set for pages
Bulding off of this response from @kaiser about being able to filter by post types on a search page, I wanted to be able to automatically add-in all of the public post types available. So, after some ...