Articles of posts

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

I’ve got a custom WP_Query loop based of meta_value variables: $meta_cat = get_sub_field(‘category’); $posts = new WP_Query( array( ‘cat’ => $meta_cat, ‘posts_per_page’ => get_sub_field(‘recent_ppp’), ) ); But somehow when I’ll make a post sticky it isn’t shown as the first item in the while loop. I know ignore_sticky_posts is default set to false so I […]

Get current post id in functions.php

I have a wp_localize_script() function in my functions.php where I need to push the current post ID of the current post to a jQuery file. So I was wondering how you can get the current post ID of a post in my functions.php. These are both not working: global $post; $post_id = $post->ID; global $wp_query; […]

Post featured image column on admin post list page

I have a client site which accepts images from users as posts. For moderation, we are opening each draft post which obviously takes a lot of time if a hefty amount of images are moderated. So, Is there a way to show featured images of the post on the admin post list page as a […]

Allow variable amount of comments before pagination

There is an option in the admin settings allowing you to define how many comments should be listed before creating a new page for the next ones. I would like to have the same number of comments for all my posts unless it belongs to one specific category (where I would like to set a […]

Different number of posts in each category

I have categories driven site. I have different template for each category. I would like to set different number of posts – different for each category. Plus I would like to add proper previous and next links in each category. for example in this category-1.php I want 4 posts per page: <?php query_posts(‘showposts=4’); ?> <a […]

Passing a hardcoded page/post ID into `get_post`

I see people using this to pull in page content on their home pages, remove specific categories from archives etc.. e.g. $post = get_post( 5 ); Someone suggested this was bad practice. Why is it bad and what should users do instead?

The next_posts_link() works only with original $wp_query

I’ve got custom template that I want to display paged blog posts. This is the beginning of my file: $wp_query = new WP_Query($args); if($wp_query->have_posts()){ while($wp_query->have_posts()){ $wp_query->the_post(); //something… <?php next_posts_link(‘Older Entries’); ?> <?php previous_posts_link(‘Newer Entries’); ?> It works fine – it displays OLDER and NEWER links when it should. On the first page it will display […]

How can you change the 'Insert into Post' title in the media button?

Actualy the question says it all. I integrated a media upload box to my admin page and a button with the text ‘Insert into post’ makes no sense. I rather like to change it to something like ‘Use this image’. Anyone got a clue on how you are able to do so?

Rewriting post slug before post save

I need to retrieve an ACF field within the post, and change the slug(permalink) of the post before saving it to database. What is the approach to achieve that? I need the slug to be changed every create/edit post operations.

Get post content by ID

How can I get a post’s content by post id? I tried get_page(‘ID’); to show content but it does not work.