Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using the hyphenator.js to custom page template and works for paragraph, but I can not apply it to Post. How can do that?

header.php

<script type="text/javascript" src="https://raw.github.com/bramstein/hypher/master/dist/jquery.hypher.js"></script>

    <script type="text/javascript">
    jQuery(document).ready(function($)
    {
     $(function() {
     $('p').hyphenate('en');
      });
    });
    </script>

style.css

post-single {text-align:justify; font-size:1em;}

single-news.php

<div class="post-single" id="post-<?php the_ID();?>">
<div class="title-single"><h3><?php the_title(); ?></h3> </div>
<div class="posted">
<em>Posted <?php the_time('l, j F Y') ?>.</em></div>

        <?php the_content (); ?>

</div>  

The problem with the class resolved, but the hypernate .js doesn't work to IE. How can fix that?

share|improve this question

1 Answer 1

While inserting js directly in header.phpcan work it's not recommanded to do that. You'd better add your scripts to the WordPress queue:

function wpse_109879_insert_hyphenator() {
 wp_register_script('hyphenator', 'https://raw.github.com/bramstein/hypher/master/dist/jquery.hypher.js', array('jquery'), null , false);
 wp_enqueue_script('hyphenator');
}

add_action('wp_enqueue_scripts','wpse_109879_insert_hyphenator');

Regarding CSS you probably use the wrong class, you can try .single-post or .single

EDIT: I see you use raw script. Maybe you'd better copy paste code from github into another js file you can call directly from your theme. This would allow to insert code you use to initialize hyphenator so you have only one file to manage hyphenator.

share|improve this answer
    
i add more information about 'single-news.php'. If i add his script to WP queue, the hyphenator don't work for custom page template. –  MikeD Aug 13 '13 at 12:15
    
After many times of efforts. Ι "reload" the js of language and the script load for paragraphs of post. I think that the problem, that the problem resolved but I say that with caution. –  MikeD Aug 13 '13 at 14:19
    
But the text-justify and hyphenator.js doesn't work for other browsers like Chrome and IE. How can fix that? –  MikeD Aug 31 '13 at 11:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.