page 1 is not paged

do you mean you want a conditional for page 1 of all home queries which have more than one page as result? try to use $wp_query->max_num_pages; example: if (is_home() && $wp_query->max_num_pages > 1 && !is_paged()) echo ‘/page/1’; else echo “https://wordpress.stackexchange.com/”;

How can I fix this code [duplicate]

prepare has always required two arguments, it just didn’t throw an error when used incorrectly until 3.5. Basically, the use of prepare in this case is not doing anything. Since you’re not passing potentially unsafe data to the query, you can remove it entirely to get rid of the error and just pass your query … Read more

Strip hashtag off permalink with php

echo get_permalink($post);, or the_permalink() in the Loop context, will give you the canonical URL for the post, without the trailing hashtag part– technically the ‘fragment’. You could also use PHP’s parse_url to break the URL apart if *_permalink functions don’t work for you for some reason, or even PHP’s strpos and substr for a really … Read more

Adding an Unlinked Space in a Custom Function

In my opinion CSS isn’t the right way, it should be a “real” space. Also there is no class to target the differents links in the string. Try this code: function wp_link_pages_args_prevnext_add($args) { global $page, $numpages, $more, $pagenow; if($page-1) # there is a previous page $args[‘before’] .= ‘ ‘. _wp_link_page($page-1) . $args[‘link_before’] . $args[‘previouspagelink’] . … Read more

WordPress SQL JOIN query

If you are going to do this is SQL, use a subquery. SELECT *, (SELECT meta_value FROM wp_commentmeta WHERE meta_key = ‘your-meta-key’ AND wp_commentmeta.comment_id = wp_comments.comment_ID LIMIT 1) as comment_author FROM wp_comments Instead of the *, enumerate the fields you want but leave out comment_author. Obviously, $wpdb functions to keep the table names straight.

Stuck with sidebar registering

get_sidebar(‘dfth’) looks for a sidebar-dfth.php file in your template directory. If not found, it loads the default sidebar. To call the sidebar you registered in a template, use e.g. <?php if ( is_active_sidebar( ‘dfth’ ) ) : ?> <div class=”first dfth-widgets”> <?php dynamic_sidebar( ‘dfth’ ); ?> </div><!– .first –> <?php endif; ?>