List all posts from past week grouped by sub-category

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( ‘cat’ … Read more

Inserting custom data to the_post() during loop

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 to objects. Don’t … Read more

Display the_content on click jquery

Please try the following javascript you need to add class to a tag for read more <a class=”readmode”>Read More</a> $(‘.readmode’).click(function() { $(this).siblings(‘.pop’).slideToggle(); return false; }); Here is the demo http://jsfiddle.net/fvcvyc1e/4/

Loading post template that contains a nested loop with ajax

Your inner loop overwrites the contents of $post, so any later template tags use the values of whatever it last contained. “But I used wp_reset_postdata()!” you say? What that function does is try to restore $post from $wp_query->post. It’s meant to restore the main query after secondary queries. You have two secondary queries here, so … Read more

Get posts by name and taxonomy term

Note that if you have the post slug, you don’t need the additional taxonomy query to find that post, so it makes sense to drop the expensive taxonomy query in core in that case. Otherwise you could try instead the post_name__in parameter: [ ‘post_name__in’ => [ ‘<postslug>’ ], ‘tax_query’ => [ [ ‘taxonomy’ => ‘<taxonomy>’, … Read more

get_posts that match a user-specified value on a page

Using a variable will make your code a little less repetitive: $case_history_code = get_field( ‘case-history-code’ ); if ( $case_history_code ) { // make the code lowercase $case_history_code_lower = strtolower( $case_history_code ); // use the lowercase inside of `get_posts` $myposts = get_posts( ‘numberposts=3&offset=0&category_name=” . $case_history_code_lower ); foreach ($myposts as $post) : setup_postdata($post); ?> <a href=”https://wordpress.stackexchange.com/questions/220489/<?php the_permalink(); … Read more

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