Ask your WordPress questions! Pay money and get answers fast! (more info)

IE Rendering Issues WordPress

  • SOLVED

I'm having some major issues with this site. I did not build, and am not a coder, but I can copy and paste :)

http://feedingsga.org/

When you have a link at the beginning of a news post, it messes up the entire display of the site, especially in IE.

Answers (1)

2014-05-30

Dbranes answers:

Can you post the link to a post with this problem?

... or do you mean it happens on the frontpage, when you show the excerpt ?

ps: you should really do something about the Recent-Photos widget, it's displaying many photos in full size, 2MB each. The site takes for ever to load with it.


Anne Shenton comments:

It happens on the front page. The excerpt doesn't pull up and it messes up the display of the homepage.


Dbranes comments:

I wonder if you use <em>substr()</em> to construct the excerpt,
and when you got a link at the beginning of a post,
it cuts into the middle of the link, and messes up your site.

Can you post the relevant code ?


Dbranes comments:

In general I would expect to see the WordPress function [[LINK href="http://codex.wordpress.org/Function_Reference/the_excerpt"]]<em>the_excerpt()</em> [[/LINK]] used instead of the <em>substr()</em> function.


Anne Shenton comments:

Again, I'm not a coder, but I hope this is the relevant code you need, from the index.php file:

<!-- ================================================== PRIMARY AREA ================================================== -->
<div class="row">
<div class="col-md-8 left-side">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<div class="row">
<div class="col-xs-4 col-md-4">
<h3>Recent News</h3>
</div>
<div class="col-sm-2 col-sm-offset-6 col-md-2 pull-right"><a href="recent-news" class="more">More<i class="glyphicon glyphicon-play more-icon"></i></a></div>
</div>
<div class="row articles white shadow">
<?php $query = new WP_Query( array('category_name'=>'news','orderby'=>'date','order'=>'DESC', 'posts_per_page'=>2)); ?>
<?php if ($query->have_posts()){ ?>
<?php while ($query->have_posts()) { ?>
<?php $query->the_post(); ?>
<div class="row aricle-post">
<div class="col-sm-3 col-md-3 featured-image">
<?php if(has_post_thumbnail()){ ?>
<?php the_post_thumbnail( array(125,125) ); ?>
<?php } else { ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/post-1.jpg" alt="post image">
<?php } ?>
</div>
<div class="col-sm-9 col-md-9">
<a href="<?php echo get_permalink();?>"><h4><?php the_title(); ?></h4></a>
<h5 class="content-date">
Posted in News Category by <?php the_author(); ?> on <?php the_time('F d, Y'); ?>
</h5>
<p class="posts">
<?php echo content(101); ?>
</p>
</div>
</div>
<?php
}
}
wp_reset_postdata();
?>
</div><!--end articles-->


Dbranes comments:

ok thanks, it looks like this function:

<?php echo content(101); ?>

is rendering out the excerpt.

I would expect to see it defined in the <em>functions.php</em> file.

Can you please post this content function as well?


Anne Shenton comments:

<?php
/**
* secondeharvest functions and definitions
*
* @package secondeharvest
*/

/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) )
$content_width = 640; /* pixels */

if ( ! function_exists( 'secondeharvest_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*/
function secondeharvest_setup() {

/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on secondeharvest, use a find and replace
* to change 'secondeharvest' to the name of your theme in all the template files
*/
load_theme_textdomain( 'secondeharvest', get_template_directory() . '/languages' );

/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );

/**
* Enable support for Post Thumbnails on posts and pages
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
//add_theme_support( 'post-thumbnails' );

/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'secondeharvest' ),
) );

/**
* Enable support for Post Formats
*/
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );

/**
* Setup the WordPress core custom background feature.
*/
add_theme_support( 'custom-background', apply_filters( 'secondeharvest_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
}
endif; // secondeharvest_setup
add_action( 'after_setup_theme', 'secondeharvest_setup' );

/**
* Register widgetized area and update sidebar with default widgets
*/
function secondeharvest_widgets_init() {
register_sidebar( array(
'name' => __( 'Front Page Sidebar', 'secondeharvest' ),
'id' => 'sidebar-1',
'before_widget' => '<div class="row gallery"><div class="col-md-12"><div class="row calendar white shadow">',
'after_widget' => '</div></div></div>',
'before_title' => '<h3 class="sidebar">',
'after_title' => '</h3>',
) );

register_sidebar( array(
'name' => __( 'Internal Page Sidebar', 'secondeharvest' ),
'id' => 'sidebar-2',
'before_widget' => '<div class="row gallery"><div class="col-md-12"><div class="row calendar white shadow">',
'after_widget' => '</div></div></div>',
'before_title' => '<h3 class="sidebar">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'secondeharvest_widgets_init' );

/**
* Enqueue scripts and styles
*/
function secondeharvest_scripts() {
wp_enqueue_style( 'secondeharvest-style', get_stylesheet_uri(), array(), '2013101620');

wp_enqueue_style( 'secondeharvest_custom-style', get_template_directory_uri().'/css/custom_style.css', array(), '10043'); /*, array(), '10037'*/

wp_enqueue_script( 'secondeharvest-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );

wp_enqueue_script( 'secondeharvest-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}

if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'secondeharvest-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
}
}
add_action( 'wp_enqueue_scripts', 'secondeharvest_scripts' );

/**
* Implement the Custom Header feature.
*/
//require get_template_directory() . '/inc/custom-header.php';

/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';

/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';

/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';

/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';

require get_template_directory() . '/inc/foo.widget.class.php';

require get_template_directory() . '/inc/photogallery.widget.class.php';

require get_template_directory() . '/inc/calendarevent.widget.class.php';

require get_template_directory() . '/inc/emailsignup.widget.class.php';

require get_template_directory() . '/inc/customsearch.widget.class.php';



/**
* Custome added
*/
function content($limit) {

$content = substr(get_the_content(), 0, $limit);
$content .= "...";

$content = preg_replace('/\[.+\]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);

return $content;
}


Dbranes comments:

aha, just as I expected, this function is using <em>substr()</em> to generate the excerpt.

That explains your problems.

Try to replace

<?php echo content(101); ?>


with

<?php the_excerpt();?>


Dbranes comments:

Additionally add the following to your functions.php file:

/**
* Add ... after each excerpt
*/

function wpq_excerpt_more( $more ) {
return '&hellip;';
}

add_filter( 'excerpt_more', 'wpq_excerpt_more' );


/**
* Change the excerpt length
*/

function wpq_excerpt_length( $length ) {
return 101; // Modify this to your needs
}

add_filter( 'excerpt_length', 'wpq_excerpt_length', 99 );