WP_Query offset argument does not work

The offset index for WP_Query generally works with pagination. When you set pagination to a -1 the function assumes you’re getting all posts and there will be no pagination or offset. So to counteract this you would set the posts_per_page to a high number like 999. Reading the Function Reference on WP_Query the pagination section … Read more

Ajax Load More Posts in Category Page

Your query parameters don’t contain any category arguments. You need to pass and set cat or category_name along with the post type, offset, and posts per page. You can get the current category’s ID via get_queried_object(): $queried_object = get_queried_object(); $cat_id = $queried_object->term_id; Output and retrieve the value somewhere in your category template, or better, when … Read more

Allow variable amount of comments before pagination

This have several components to it – what option itself holds and how value from it is stashed away and reused by various pieces of core code. I am not sure this is perfect, but my quick take would be: new Adjust_Comments_Per_Page( 10, ‘years’, ‘category’ ); class Adjust_Comments_Per_Page { private $amount; private $term; private $taxonomy; … Read more

How to mark articles as read?

For a truly full solution you need to have all the users to have an account (or create one when marking as read) and you associate in the DB the user with the posts that he read and then style each link appropriately. To implement this you can look for inspiration in plugins that add … Read more

Is it possible to bold certain words in a post title?

Yes, you can use HTML elements in post titles by default. If your output is escaped a plugin or theme might have touched that. Disable all plugins and switch to TwentyEleven. This will help you to identify the source. Note that markup is stripped in some places where it is not allowed: title attributes and … Read more

Is it possible to Schedule Attachments in WordPress?

My idea is that you can setup a post date for the attachments. This can be done using attachment_fields_to_edit to show the UI (is possible use the touch_time internal function). After that, you can filter all the attachments query to show only the attachments with a past or current date. So add_action(‘load-post.php’, ‘setup_attachment_fields’); function setup_attachment_fields() … Read more

WP_Query: Why is sticky post not first item in loop?

If you look ate the source code where stickies are included, we find the following condition before WP_Query carries on to include sticky posts if ( $this->is_home && $page <= 1 && is_array($sticky_posts) && !empty($sticky_posts) && !$q[‘ignore_sticky_posts’] ) { The big game player is the is_home condition. Conditionals inside WP_Query is set according to the … Read more

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