Using in_category for non standard loops
Figured it out. Just need to add $post_id to the template tag like so. if (in_category(‘videos’,$post_id)) {
Figured it out. Just need to add $post_id to the template tag like so. if (in_category(‘videos’,$post_id)) {
After researching this, here is what works for me: <?php $paragraphAfter= 1; //show box after selected paragraph $content = apply_filters(‘the_content’, get_the_content()); $content = explode(“</p>”, $content); for ($i = 0; $i <count($content); $i++) { if ($i == $paragraphAfter) { ?> <!– START OF BLOCKQUOTE –> stuff <!– END OF BLOCKQUOTE –> <?php } echo $content[$i] . … Read more
That plugin is 3 years old. I’m not sure if it uses the menu_order column to set the order but if it does you can filter pre_get_posts or your custom query with: ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’ This would all have to be done before the $post object is added to the $events array … Read more
If you are inside the loop, on the single page, than you have all tags and can search for releated posts with the same tags. You find many solutions via google; an example: //for use in the loop, list 5 post titles related to first tag on current post $tags = wp_get_post_tags( get_the_ID() ); if … Read more
Here is an idea: Use get_posts() to get posts you want. On the right hand side show titles via foreach. use setup_postdata() on right hand side loop to get post content. You can use jquery tabs to show and hide post content or just use jquery. Don’t do get_posts() twice or use ajax because you … Read more
Why are you running a complete new query for every single post? Here is what is happening: WordPress gets all the posts in the category then gets your template and sees the loop ( if have_posts() etc… ) and says ok I have all these posts from this category now it’s time to display them. … Read more
I think that the only way is to query the database with LIKE statement and get all IDs and then create a separate WP_Query object for the list of post ID’s. Check this guide for example.
You can customise the loop query to get results based on a search term – with $s being the search term; <?php // Post Query $args=array( ‘s’ => $s, ); ?> <?php query_posts($args); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
You can achieve this by checking where you are in the loop and outputting markup at the appropriate time. Within the object that holds the query results is a counter that keeps track of the current post, $wp_query->current_post. Note that it is zero-indexed, so first is 0, 2nd is 1, etc.. <?php while( have_posts() ): … Read more
Use a 2 loops in your template file with wp_query. Check the codex page for the correct parameters