get_next_posts_link() returns no result despite available posts

get_next_posts_link() and get_previous_posts_link() are for linking between pages of a paginated post archive. For navigation between individual posts you want get_next_post_link() and get_previous_post_link(). Note the singular “post”. function myslug_render_post_navigation(){ echo get_next_post_link( __( ‘Previous post’ ) ) . ‘ | ‘ . get_previous_post_link( __( ‘Next post’ ) ); } add_action( ‘genesis_after_entry’, ‘myslug_render_post_navigation’ ); genesis(); I’ve noticed … Read more

Set site title & tagline with wp.config or function.php

These fields have the keys ‘blogname’ and ‘blogdescription’ respectively in the options table. I’m not sure exactly why you need to do this as it seems like a priority to secure your site and be able to update it through the dashboard yourself, but you can update them easily from functions.php with update_option, e.g.: update_option( … Read more

List all blogs, but exclude the main site

I’ve never used it, but it looks like get_main_site_id is what you want to figure that out, so therefore your code might look like: $mainSiteId = get_main_site_id(); foreach ($user_blogs AS $user_blog) { if ($userblog->site_id != $mainSiteId) { echo ‘<li><a href=”‘.$user_blog->siteurl.'”>’.$user_blog->blogname.'</a></li>’; } }

Undefined offset: 3 in custom function

You assumed get_field would always return images, but what if there are no images to return? $images = get_field(‘fl_gallery’); $image = $images[$no]; The code never checks $images to see if it’s empty, or an error value. On top of that, what if it returned images, but it returned 3 images, and $no is 4? You … Read more

Remove extract from function

It’s very simple: Just assign the value of shortcode_atts() (which is an array) to a variable and use it to access the shortcode attributes in the same way you access the items in any other arrays: $atts = shortcode_atts( array( ‘no’ => 1, ), $atts ); // Use $atts[‘no’] to get the value of the … Read more

Export Form Data to a CSV then send it as an attachment – contact form 7

There are a few things omitted in the above solution, like defining the most params of wp_mail. Also I didn’t want to send yet another concurrent email, but instead attach the csv directly to the mail that wpcf7 sends. I think this is the cleaner solution. Here’s my take: add_filter( ‘wpcf7_before_send_mail’, ‘add_form_as_attachment’, 10, 3 ); … Read more

Send a mail to specific address in a custom field when a new comment is made on a specific post

It sounds like it’s not working because you’re hooking into comment_post, which is when the comment is created If you change the status of the comment, the comment already exists, and therefore no email is generated. There is a comment status change hook: comment_{$old_status}_to_{$new_status}. It fires anytime a comment’s status changes from one specified status … Read more