Tag: Wordpress

A Fix For WordPress Photo Captions On Responsive Themes

Code

My current WordPress Theme is Responsive and most images work correctly with the CSS, but I was having an issue with photos with captions breaking the responsive designs. I tried a few CSS fixes and didn’t see any change in how the images were being handled on my iPhone.

I came across this function code which works for me. It helps to resize the captioned photos in WordPress when using responsive themes.

https://gist.github.com/jentanbernardus/3023022

add_filter( 'img_caption_shortcode', 'dap_responsive_img_caption_filter', 10, 3 );
 
function dap_responsive_img_caption_filter( $val, $attr, $content = null ) {
  extract(shortcode_atts( array(
    'id' => '',
    'align' => '',
    'width' => '',
    'caption' => ''
    ), 
  $attr));
  
  if ( 1 > (int) $width || empty($caption) )
    return $val;
 
  if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
 
  return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="max-width: 100% !important; height: auto; width: ' . (10 + (int) $width) . 'px">'
  . do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';
}
									

Required+ Foundation Full Search Results

Code

Want Full Search Results in a Required+Foundation child theme? Here is how to do it.

This is for Required+ Foundation version 1.0.10

Find and remove or comment out the lines marked remove below in Content.php:

Original file with comments saying what to remove:

<?php
/**
 * The default template for displaying content single/search/archive
 *
 * @package required+ Foundation
 * @since required+ Foundation 0.3.0
 */
?>
  <!-- START: content.php -->
  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
      <?php if ( is_single() ) : ?>
      <h1 class="entry-title"><?php the_title(); ?></h1>
      <?php else : ?>
      <?php the_post_thumbnail(); ?>
      <h1 class="entry-title">
        <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'requiredfoundation' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
      </h1>
      <?php endif; // is_single() ?>
    </header><!-- .entry-header -->
    <?php if ( 'post' == get_post_type() ) : ?>
    <div class="entry-meta">
      <?php required_posted_on(); ?>
      <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
      <span class="label radius secondary"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'requiredfoundation' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php _ex( 'Featured', 'Post format title', 'requiredfoundation' ); ?></a></span>
      <?php endif; ?>
    </div><!-- .entry-meta -->
    <?php endif; ?>

<!-- Remove From Here -->

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class="entry-summary">
      <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php else : ?>

<!-- To Here -->

    <div class="entry-content">
      <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'requiredfoundation' ) ); ?>
      <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'requiredfoundation' ) . '</span>', 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->

<!-- Remove From Here -->

    <?php endif; ?>

<!-- To Here -->

    <footer class="entry-meta">
      <?php if ( 'post' == get_post_type() ) : ?>
      <?php get_template_part('entry-meta', get_post_format() ); ?>
      <?php endif; ?>
    </footer><!-- #entry-meta -->

  </article><!-- #post-<?php the_ID(); ?> -->
  <!-- END: content.php -->
									

New file with excerpts for search coce removed.

<?php
/**
 * The default template for displaying content single/search/archive
 *
 * @package required+ Foundation
 * @since required+ Foundation 0.3.0
 */
?>
  <!-- START: content.php -->
  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
      <?php if ( is_single() ) : ?>
      <h1 class="entry-title"><?php the_title(); ?></h1>
      <?php else : ?>
      <?php the_post_thumbnail(); ?>
      <h1 class="entry-title">
        <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'requiredfoundation' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
      </h1>
      <?php endif; // is_single() ?>
    </header><!-- .entry-header -->
    <?php if ( 'post' == get_post_type() ) : ?>
    <div class="entry-meta">
      <?php required_posted_on(); ?>
      <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
      <span class="label radius secondary"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'requiredfoundation' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php _ex( 'Featured', 'Post format title', 'requiredfoundation' ); ?></a></span>
      <?php endif; ?>
    </div><!-- .entry-meta -->
    <?php endif; ?>

    <div class="entry-content">
      <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'requiredfoundation' ) ); ?>
      <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'requiredfoundation' ) . '</span>', 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->


    <footer class="entry-meta">
      <?php if ( 'post' == get_post_type() ) : ?>
      <?php get_template_part('entry-meta', get_post_format() ); ?>
      <?php endif; ?>
    </footer><!-- #entry-meta -->

  </article><!-- #post-<?php the_ID(); ?> -->
  <!-- END: content.php -->
									

Using Jetpack Comments with Required+ Foundation

coding

I wanted to use the WordPress Jetpack Comments feature on my site and found that the form wasn’t showing up with the original code for my site which uses the Required + Foundation basic framework so I did a quick search on Google and found a solution was to insert the comment form code into the comments.php instead of using the older comments template.

Here is some code to help add the comment form to the comment.php for the Require+Foundation theme framework. Not sure if this is the best way to do it, but it seems to work for me here on this site.

This is for Required+ Foundation version 1.0.10

Modified code with comments:

<?php
/**
 * The template for displaying Comments.
 *
 * The area of the page that contains both current comments
 * and the comment form. The actual display of comments is
 * handled by a callback to required_comment() which is
 * located in the functions.php file.
 *
 * @package required+ Foundation
 * @since required+ Foundation 0.3.0
 */
?>  <!-- START: comments.php -->

  <div id="comments">


  <?php if ( post_password_required() ) : ?>
    <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'requiredfoundation' ); ?></p>
  </div><!-- #comments -->
  <?php
      /* Stop the rest of comments.php from being processed,
       * but don't kill the script entirely -- we still have
       * to fully load the template.
       */
      return;
    endif;
  ?>

  <?php // You can start editing here -- including this comment! ?>

  <?php if ( have_comments() ) : ?>
    <h2 id="comments-title">
      <?php
        printf( _n( 'One thought on “%2$s”', '%1$s thoughts on “%2$s”', get_comments_number(), 'requiredfoundation' ),
          number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );
      ?>
    </h2>

    <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
    <nav id="comment-nav-above">
      <h1 class="assistive-text"><?php _e( 'Comment navigation', 'requiredfoundation' ); ?></h1>
      <div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'requiredfoundation' ) ); ?></div>
      <div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'requiredfoundation' ) ); ?></div>
    </nav>
    <?php endif; // check for comment navigation ?>

    <ol class="commentlist">
      <?php
        /* Loop through and list the comments. Tell wp_list_comments()
         * to use required_comment() to format the comments.
         * If you want to overload this in a child theme then you can
         * define required_comment() and that will be used instead.
         * See required_comment() in required/functions.php for more.
         */
        wp_list_comments( array( 'callback' => 'required_comment' ) );
      ?>
    </ol>

    <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
    <nav id="comment-nav-below">
      <h1 class="assistive-text"><?php _e( 'Comment navigation', 'requiredfoundation' ); ?></h1>
      <div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'requiredfoundation' ) ); ?></div>
      <div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'requiredfoundation' ) ); ?></div>
    </nav>
    <?php endif; // check for comment navigation ?>

  <?php
    /* If there are no comments and comments are closed, let's leave a little note, shall we?
     * But we don't want the note on pages or post types that do not support comments.
     */
    elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) :
  ?>
    <p class="nocomments"><?php _e( 'Comments are closed.', 'requiredfoundation' ); ?></p>
  <?php endif; ?>

  <?php if ( comments_open() ) : ?>


<section id="respond">

/** Replace Reqired Code With The Comment Form Call */

<?php comment_form(); ?>

</section>

<?php endif; // if you delete this the sky will fall on your head ?>

</div><!-- #comments -->
<!-- END: comments.php -->
									

Site Updated With Required+ Foundation

required

I have used several different theme frameworks for the base of my site. I started the new look for my site by modifying an existing theme called Delicate. Delicate is a nifty little theme, but I wanted a bit more so I moved to Paglines. Pagelines gave me more than I ever needed in a theme framework and I found myself not using most of what was there.

I began looking into making my own themes and decided to look for a free framework that I could base my new themes on and came across Foundation. I poked around a bit more and found out some nice people had already setup the Foundation bits to work with WordPress. I tried out WP-Foundation, Reverie and a few others.

I ended up choosing to go with required+ Foundation. I chose required+ Foundation because it was already setup with the child theme in mind. Although it is pretty easy to create a child theme for any Worpdress theme it was nice that the groundwork was already there. Required+ Foundation is also the new hot thing on the block. It doesn’t bother with options so everything is done in code which will help with my development as a designer.

I have required+ Foundation setup here on my CookeFamily Blog and over at The Sammo Project. I plan on working out some new styles via child themes for distribution in the future.

Widget Logic WordPress Plugin

Using WordPress? Have you ever wanted to have specific widgets only appear on specific page, or have you ever wanted to not display certain widgets on specific pages?

Widget Logic makes it easy to do both of those things and a lot more. The basic widget logic plugin allows you to use conditional tags on each of your widgets telling them where to or where not to show up on your site. You can do it by post, page, category, and much more.

Just toss in the code or a combo of tag/code bits and poof you are all set for displaying widgets where you want them and hiding them from the parts of your site where you don’t.

 

Building on Widget Logic, there is also a plugin called Widget Logic Visual, which allows you to visually assign the conditional tags to your widgets via a pop up window. This bit is great if you plan to allow your clients to edit their own widget placement.

WordPress Backup

Backups are important, be it computer data backups or website/Wordpress backups. You can get backups through your host, Cpanel/Plesk, whatever, but sometimes it is nice to have WordPress backups either for backup purposes or for transferring from one web host to another.

Two tools I like that make WordPress backups a snap are BackWPup and BackupBuddy. Both of these plugins do a similar job and they do it well. You can even use both to have double backups. Both allow for local backups and offsite backups. You can schedule your backups to run at pretty much any interval with either plugin.

BackWPup is free, but offers little to no support. You pretty much only get what you can find in a google search.

Backupbuddy is $75 to $150 depending how many sites you want to use it on, but you get full support.

BackWPup is my current favorite of the two. I like that it is more visual in what it is doing.

I have also not run into as many errors in the backup process with BackWPup as I did with Backupbuddy, but then again I am only using it on one host which has worked well with both plugins.

Backupbuddy is overall pretty decent. I did run into a couple of issues depending on what host my clients were using, but overall it did the job as needed. There were a lot of times where I got errors and really had no idea why. Most of the errors ended up being size related, removing older files and folders from backups seemed to help with most errors I came across.

The best part about backup buddy is the import buddy script. Import buddy is an almost one click solution for transferring your site from one host to another. Great for a developer who needs to develop a site on a test server then transfer the full site over to a client’s hosting service.

If you know what you are doing with a zip of your files and a database file then you will do fine with BackWPup. If you need a little more hand holding I totally recommend Backupbuddy. You can’t go wrong with either choice, just make sure you are backing your stuff up.