Tag Info

New answers tagged

0

A search through the plugin your code is based on indicates everything in your question is your own modifications. The problem you face is that you're serialising PHP arrays and storing them in post meta, then attempting to run queries on them. This does not work, and never will work. The example value you provided a:1:{i:0;s:3:"11687";} is equivalent to ...


0

Replace the '#textbox' html with the following and css: <div class="textbox"> <div class="textbox_left"> <p class="txtclhome"><?php dynamicnews_display_thumbnail_index(); ?> </p> </div> <div class="textbox_right"> <h3 class="titlehome"><a href="<?php the_permalink() ?>" ...


0

Two problems here: Never use the same exact names for variables, always make them unique. Naming them the same is confusing and might cause conflicts later on with other non related code. It also makes debugging easier You have to reset all instances of WP_Query. This is very very important, and one thing that you will have to teach yourself as standard ...


1

Well, you need to include the type comparison, or alphanumeric comparison is applied here. In this case, you should add 'type' => 'numeric'. Using Your Class Function <?php public function list_related_docs($id){ $docs_args = array( 'post_type' => 'publication', 'post_status' => ...


1

Your tax query is incorrect, field should be the field you want to query on: term_id, name, or slug - $posts_array = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'fabric_building', 'tax_query' => array( array( 'taxonomy' => 'fabric_building_types', 'field' => ...


0

To include custom post time in the $author_query array, add another key=>value element to $author_query array. Example: $author_query = array( 'posts_per_page' => '-1', 'author' => $current_user->ID, 'post_type'=>'your custom post type name' );


1

You should use get_terms() for taxonomies when you can. <?php /* Add your taxonomy. */ $taxonomies = array( 'fabric_building_types', ); $args = array( 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true, 'exclude' => array(), 'exclude_tree' => array(), ...


1

Yep, it's not very common, but perfectly viable and nifty technique. After the posts are retrieved in WP_Query they are passed through the_posts filter like this (where $this is WP_Query instance): $this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) ); You just loop through array and assign the extra data you need ...


0

I am pretty sure that those query variables only work on index pages-- pages that WordPress considers indexes not pages that you have hacked into indexes. Basically, other people are telling you the same thing. Unless I am misunderstanding you, I would suggest that you create a custom post type for this data instead of trying to use pages. ...


2

You have a couple of problems with your code customtaxonomy=$mytaxonomy is incorrect. First of all, there is no parameter called customtaxonomy in get_posts. Secondly, your syntaxing is wrong. If you make use of a varaible, your syntaxing should look like this 'post_type=myposttype&customtaxonomy=' . $mytaxonomy . '&posts_per_page=-1' You should ...


1

In your function, you have this line: $mytaxonomy = get_posts('post_type=myposttype&$customtaxonomy=$mytaxonomy&posts_per_page=-1'); Try changing it to: $mytaxonomy = get_posts('post_type=myposttype&customtaxonomy=$mytaxonomy&posts_per_page=-1'); $customtaxonomy is a variable. customtaxonomy is a parameter.


1

I would recommend that you use WP_Query for this one: $categories = get_categories( 'child_of=83' ); foreach ( $categories as $category ) { echo '<h3>' . $category -> name . '</h3>'; echo '<ul>'; // create a WP_Query that retreives all posts from the specified // category which is older then 1 week $args = array( ...


0

You can print your id echo $termss->term_id in drop down $terms = get_terms( 'category', array( 'hide_empty' => false, 'order_by' => 'name', 'order' => 'ASC', 'number' => 0, 'taxonomy' => 'category' ) ); //print_r($terms); foreach($terms as $termss) { //echo "<br/>"; //echo ...


0

You can use transient cache to cache your custom query. Here is a simple code to set_transient cache for your query for 12 hours. In 12 hours WordPress will not make new query but fetch posts from transient. On expiration, it will save new query in transient again for next 12 hours. I have been using transient for many queries on my website but make sure ...


-4

You can use the pre_get_post-hook to get the number of posts that you want to display: add_action( 'pre_get_posts', 'your_function_name' );


2

The "limit" parameter does not work because there is no such parameter in get_posts or any other query in WordPress. You can use posts_per_page to set the number of posts to retrieve, and offset to have it skip certain numbers of posts. These are the only parameters you can use, and together, they change the resulting LIMIT in the SQL query that is ...


0

I have solved this problem, I have used the posts_per_page parameter with a value of 100 and used jPages for jQuery pagination. Explanation: As I needed to pull a limited number of posts - in my case, 210 - I wanted to use both pagination and a query limit. As this seems to be impossible using get_posts(), I used the posts_per_page parameter with a value of ...


1

You can use posts_per_page or numberposts. http://codex.wordpress.org/Template_Tags/get_posts#Parameters EDIT: Regarding your edit. You cannot have the posts_per_page different to the LIMIT in the SQL query. get_posts() creates an instance of WP_Query and returns it using the posts_per_page as the LIMIT.


2

Please try this instead: $args = array( 'post__in' => $post_ids, ); $posts = get_posts( $args ); Lesson learned: Always check your PHP scripting errors! ;-) Check for example this Codex page on debugging.



Top 50 recent answers are included