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

Is this plugin safe to run?

wpdb::_insert_replace_helper() will escape the data: return $this->query( $this->prepare( $sql, $data ) ); But still … the base64 encoded string looks odd. That should have been four separate parameters, I think.

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; ?>

Closing WP_LINK_PAGES DIV ID w/After Argmuent

First, declare the after arg at the beginning of your code: $args[‘before’] = ‘<div id=”link_wrap”>’; $args[‘after’] = ‘</div>’; When there is a next page, the arg is overwritten, so you’ll have to add the closing tag at the end: if ($page<$numpages) # there is a next page $args[‘after’] = ‘ ‘. _wp_link_page($page+1) . $args[‘link_before’] . … Read more