Multiple post queries -category,posts per page,orderby

You are passing the cat parameter twice– the second time is empty. $page_query = new WP_Query( ‘post_type=post&cat=145’. ‘&posts_per_page=-1&cat’ . // <– here ‘&orderby=date&order=asc’ ); Maybe it is just me, but I find those query-string-like parameters hard to read and hard to keep straight. I’d advise you to create a proper array. $page_query = new WP_Query( … Read more

Transfer taxonomy to custom field

You can order posts by custom taxonomy terms by adding a posts_clauses filter, see below answer: https://wordpress.stackexchange.com/a/14313/14499 Make sure that on functions.php you add both that function AND the call to add_filter(‘posts_clauses’, ‘orderby_tax_clauses’, 10, 2 );, otherwise it won’t work. Assuming annee is the custom taxonomy, this should then work: query_posts($query_string . ‘&posts_per_page=-1&orderby=annee&order=ASC’);

How to get alphabetic listing x other posts, based on first letter post?

For the solution you can use if statement as below put it in your sidebar, it will highlight the current post title. <ul> <?php $IDOutsideLoop = $post->ID; $args = array( ‘posts_per_page’ => -1, ‘orderby’=> ‘title’, ‘order’ => ‘ASC’ ); $myposts = get_posts( $args ); foreach($myposts as $post) : ?> <li <?php if(is_single() && $IDOutsideLoop == … Read more

How to inject a post within a loop

I am assuming you are doing something like this: if (have_posts()) { while (have_posts()) { the_post(); if(x == j){ //inject post here } } } Injecting a post inside the Loop like that will cause the post count for that page to differ from the posts_per_page value, but it will not break pagination (which seems … Read more

How to get all post titles starting with numbers and symbols?

Hook into the posts_where filter and add your condition to the query: add_filter(‘posts_where’, function($where){ global $wpdb; return “{$where} AND {$wpdb->posts}.post_title REGEXP ‘^[0-9\$\@\!\?\%]'”; // add other symbols in the regex above ^ }); Then do your query: $my_query = new WP_Query(…); You may want to remove the filter after you get the results (make it a … Read more

get_next_posts_link() stops displaying at page 4

I don’t know where $era_opts comes from but a filter on pre_get_posts should do this and preserve your pagination. function era_blog_cats_wpse_103587($qry) { if ($qry->is_page(‘your-page’) && is_main_query()) { $era_opts = get_option(‘era_opts’); // assuming that era_opts are options $blogcats = $era_opts[‘era_opts_blog_thecats’]; if(!empty($era_opts[‘era_opts_blog_thecats’])) { $qry->set(‘category__in’, $blogcats); } } } add_action(‘pre_get_posts’,’era_blog_cats_wpse_103587′); I made several assumptions about your data, but … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)