Jump to content
php.lv forumi

PHP un JS


Blumish

Recommended Posts

Sveicināti!.
Man ir tāda problēma.
Lietoju wordpress dzini. Kurā esmu ievietojis facebook komentārus. Vēlos lai šie komentāri rādās jau pirmajā lapā. To esmu panācis. Otrais ko vēlējos ir tas lai viņi defultā ir slēpti zem js, un atvert tos varētu piespiežot vienkātši "Komentāri" pogu. To arī es panācu. Bet problēma slēpjas tajā, ka komentāri atveras uzreiz visiem rakstiem, nevis vienam noteiktajam.

Šeit es iekopēšu pašu wp kodu kad izvada to sākumlapu, un js kodu kas paslējpj šos facebook komentārus.
 

<?php
/**
* Loop template
*
* This file is responsible for generating all code in
* the WordPress loop.
*
* @package     Ghostbird
* @author     Michael Fields <[email protected]>
* @copyright Copyright (c) 2011-2012 Michael Fields
* @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since     1.0
*/
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
do_action( 'ghostbird_entry_start' );
switch ( get_post_format() ) {
case 'aside' :
case 'link' :
print "\n" . '<div class="entry-content">';
the_content( __( 'Continue Reading', 'ghostbird' ) );
print "\n" . '</div><!--entry-content-->';
break;
case 'status' :
ghostbird_featured_image( '<div class="featured-image">', '</div>' );
print "\n" . '<div class="entry-content">';
the_content( __( 'Continue Reading', 'ghostbird' ) );
print "\n" . '</div><!--entry-content-->';
break;
default :
ghostbird_featured_image( '<div class="featured-image">', '</div>' );
/*
* Title only for multiple views.
* Will be displayed in single views via ghostbird_title() in an H1 element.
*/
if ( ! is_singular() ) {
the_title( "\n" . '<h2 class="entry-title"><a href="' . get_permalink() . '">', '</a></h2>' );
}
print "\n" . '<div class="entry-content">';
if ( ( is_archive() || is_home() ) && ( 'page' == get_post_type() || 'gallery' == get_post_format() ) ) {
the_excerpt();
}
else {
the_content( __( 'Continue Reading', 'ghostbird' ) );
}
print "\n" . '</div><!--entry-content-->';
wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'ghostbird' ), 'after' => '</div>' ) );
print '<div class="' . esc_attr( ghostbird_entry_meta_classes() ) . '">';
ghostbird_entry_meta_date();
ghostbird_entry_meta_taxonomy();
print '</div><!--meta-->';
break;
}
do_action( 'ghostbird_entry_end' );
?>
</div><!--entry-->
<?php
}
}
?>



Un JS, kurā jau ir iestradati facebook komentāri.
 

<script src="http://code.jquery.com/jquery-latest.js"></script>
<button style="float:right;color:#3B5998;margin-top:-2px;margin-right:5px;text-decoration:underline;"><fb:comments-count href="<?php echo get_permalink($post->ID); ?>">Komenāri</button>
<p style="display: none" class="fb-comments" data-href="<?php the_permalink() ?>" data-num-posts="2" data-width="738"></p>
<script>
$("button").click(function () {
$("p").show("slow");

});
</script>

 

 

izmēģināju šo:

 

$("button").click(function () {
$(this).next("p").show("slow");
});

 

bet arī nekā


Liels paldies, un ceru ka palīdzēsiet!

Edited by Blumish
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...