Print number of post (in reverse)

To print a decreasing counter for the main home query, without sticky posts, you can try: // current page number – paged is 0 on the home page, we use 1 instead $_current_page = is_paged() ? get_query_var( ‘paged’, 1 ) : 1; // posts per page $_ppp = get_query_var( ‘posts_per_page’, get_option( ‘posts_per_page’ ) ); // … Read more

Can’t publish new posts

There are, still, references to old domain in your database, which have to be fixed. Step 1: go to Settings -> Permalinks and click on Save Changes button. This will fix your permalinks. Step 2: install and activate Better Search Replace plugin. Go to Tools -> Better Search Replace. Replace the old domain ( example.com … Read more

If specific user role then sticky post

It looks like it is possible. Sticky posts are stored as array of IDs in an option called ‘sticky_posts`, and you can modify options using hooks, so… There is a chance that something like this would work: function fake_sticky_posts_for_author() { $user = wp_get_current_user(); if ( get_current_user_id() && in_array(‘author’, $user->roles) ) { // Return the IDs … Read more

Make custom field meta not display if there is not data in it

It could be that there are rows being returned for: have_rows(‘google_drive_links’) but then, nothing returned for the sub fields? $content = get_sub_field(‘google_link_name’); $link = get_sub_field(‘google_link’); Perhaps you could put in an extra check for those two before creating the hr and ul? if (get_sub_field(‘google_link_name’) && get_sub_field(‘google_link’)){ // Create the hr and ul } Depending on … Read more

New Plugin Review

Now I’ve seen your code, I think the reviewer is wrong: they’re talking about the form in agg-as-options.php, which is handled the way I describe below except they’re wrong: the form is processed in the agg_options function, not outside of a function as they say this is only shown and processed on the admin aggregate-options … Read more

Make `previous_post_link()` Function Show The Post After Next i.e. Jump A Post

$current_id = get_the_ID(); $cpt = get_post_type(); $all_ids = get_posts(array( ‘fields’ => ‘ids’, ‘posts_per_page’ => -1, ‘post_type’ => $cpt, ‘order_by’ => ‘post_date’, ‘order’ => ‘ASC’, )); $prev_key = array_search($current_id, $all_ids) – 2; $next_key = array_search($current_id, $all_ids) + 2; if(array_key_exists($prev_key, $all_ids)){ $prev_link = get_the_permalink($all_ids[$prev_key]); echo $prev_link; } if(array_key_exists($next_key, $all_ids)){ $next_link = get_the_permalink($all_ids[$next_key]); echo $next_link; } So I … Read more

wp_insert_post let users post to without login…broke

wp_insert_post() makes use of the current user at several points, if memory serves. So, you’d want to use wp_set_current_user() to switch that to some shared author user, and then switch it back to its original value when you’re done. Alternatively, require users to be logged in and allow all groups to create drafts.

Duplicate Posts using Feedwordpress

The FeedWordPress Duplicate Post Filter add-on might take care of this faster than trying to hunt down the root cause. It’ll probably turn out to be a problem in the feed itself, which you wouldn’t likely have any control over. Despite the formats being fairly simple and well-documented, many sites/applications just can’t seem to produce … Read more