Hide content from Post Preview
There is the handy is_preview function. So somewhere in your single.php. <?php if (!is_preview()) { // Show stuff that doesn’t belong on a preview. }
There is the handy is_preview function. So somewhere in your single.php. <?php if (!is_preview()) { // Show stuff that doesn’t belong on a preview. }
Reorder the logic, and fix the minor syntax error in your appended string: function add_post_content($content) { if ( ‘portfolio’ == get_post_type() ) return $content; if ( is_single() ) return $content . ‘<p>Shortlink: ‘ . wp_get_shortlink() . ‘</p>’; return $content; }
According to the official system requirements, PHP version 5.2.4 or greater should work. However, some plugins and / or themes may require PHP version 5.3, though. BTW, PHP 5.2 has reached its End of Life a couple of year back (in 2011).
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
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
The problem is most likely with the address you are trying to fetch, and it is extremely unlikely it relates directly to your code. You should check what url is being passed to file_get_contents to make sure it is the one you actually tried in the browser. If they are the same, it might relate … Read more
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.
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.
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; ?>
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