Vielen Dank, das war genau das Richtige! :)
Beiträge von japanworm
-
-
Hallo.
Vielen Dank. Wie erwartet klappt es mit the_category nicht.
Bei get_the_category bekomme ich den folgenden Output:Hier ist der gesamte Code der Funktion:
Code
Alles anzeigenclass CategoryThumbnail_Walker extends Walker_Category { // A new element has been stumbled upon and has ended function end_el( &$output, $category, $depth, $args ) { // Output the standard link ending parent::end_el( &$output, $category, $depth, $args ); // Get one post $posts = get_posts( array( // ...from this category 'category' => $category->cat_ID, 'numberposts' => 10 ) ); // we'll record the seen images here if ( !isset($this->images_seen) ) $this->images_seen = array(); foreach ( $posts as $post ) { // Get its thumbnail and append it to the output $featured = get_the_post_thumbnail( $post->ID, 'latestpost-thumb', null ); // have we already seen this image? if ( in_array($featured, $this->images_seen) ) continue; else { $this->images_seen []= $featured; $output .= '<a href="http://www.zoomingjapan.com/category/'.get_the_category().'" title="Category Name">'.$featured.'</a>'; break; } } } }Hier ein Livebeispiel (in der Sidebar unter Browse&Find, dem Categories Tab): klick
Der Thumbnail soll ebenfalls als Link zur entsprechenden Kategorie fungieren.
-
Hallo,
Ich habe folgendes in meiner function.php und bin mir ziemlich sicher, dass es nur ein Syntaxproblem ist, aber ich bekomme es einfach nicht auf die Reihe:
PHP$output .= '<a href="http://www.zoomingjapan.com/category/<?php the_category() ?>" title="Category Name">'.$featured.'</a>';Als Ergebnis hätte ich gerne den entsprechenden Link zur Kategorie, aber so bekomme ich nur den folgenden Output:
Das php wird nicht umgesetzt.
Vermutlich brauche ich eh eher sowas wie:
Aber auch das wird nicht umgesetzt.
Vielen Dank für eure Hilfe und sorry, wenn das eine dämliche Frage sein sollte, aber ich stehe irgendwie auf dem Schlauch :shock:
-
Hallo.
Vielen Dank für den Tipp.
Ich hab mal versucht, den von dir verlinkten Code in meinen einzubauen.
Das sieht dann so aus:PHP
Alles anzeigen<?php if ( have_comments() ) : ?> <?php if ( ! empty($comments_by_type['comment']) ) : ?> <h2 class="h2comments"><img src="http://zoomingjapan.com/wp-content/themes/alltuts-child/images/comments_big.png" /><?php comments_number('No Comments', '1 Comment', '% Comments' );?> <a href="#respond" class="addComment"><img src="http://zoomingjapan.com/wp-content/themes/alltuts/images/add_your_coment_ver2.png" border="0"></a></h2> <ul class="commentlist"> <?php wp_list_comments(array( 'callback'=>'mytheme_comment', 'type'=>'comment', )); ?> </ul> <?php endif; ?> <?php if ( ! empty($comments_by_type['pings']) ) : ?> <h2 id="pings">Trackbacks/Pingbacks</h2> <?php function list_pings($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?> <li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?> <?php } ?> <ul class="pinglist"> <?php wp_list_comments('type=pings&callback=list_pings'); ?> </ul> <?php endif; ?> <div class="navigation"> <?php paginate_comments_links(); ?> </div> <?php else : // this is displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Comments are closed.</p> <?php endif; ?> <?php endif; ?>Problem: Es zeigt nun weder die Kommentare, noch die Pingbacks an, es sei denn ich nehme das "if empty" wieder heraus.
Woran könnte das liegen?
Ich verwende momentan Wordpress 3.2 - falls das eine Rolle spielt.
Danke im Voraus :) -
Hallo.
Ich habe ein Problem mit meinen Pingbacks und den Related Posts.
Gibt es keine, wird trotzdem das CSS angezeigt (z.B. für die Related Posts der leere Container und die Überschrift etc.).Mir ist zwar klar, dass ich conditional tags benutzen muss, um das in den Griff zu bekommen, allerdings weiß ich nicht genau, wie und wo ich diese implementieren soll.
Hier der betreffende Code für die Pingbacks:
PHP<?php if ( have_comments() ) : ?> <ul class="pingbacks"><h2>Pingbacks</h2> <?php wp_list_comments(array( 'callback'=>'mytheme_comment', 'type'=>'pings', )); ?> </ul> <?php else : // this is displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Comments are closed.</p> <?php endif; ?> <?php endif; ?>Und der dazugehörige Code in der funciton.php:
PHPfunction mytheme_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?> <li <?php comment_class('clearfix'); ?> id="li-comment-<?php comment_ID() ?>"> <?php echo get_avatar($comment,$size='63'); ?> <div id="comment-<?php comment_ID(); ?>"> <div class="comment-meta commentmetadata clearfix"> <?php printf(__('<strong>%s</strong>'), get_comment_author_link()) ?><?php edit_comment_link(__('<img src="http://www.zoomingjapan.com/wp-content/themes/alltuts/images/edit.gif">'),' ','') ?> <span><?php printf(__('%1$s @ %2$s'), get_comment_date('Y/n/j'), get_comment_time('G:i')) ?> </span> <div class="text"> <?php comment_text() ?> </div> </div> <?php if ($comment->comment_approved == '0') : ?> <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em> <br /> <?php endif; ?> <div class="reply"> <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> </div> </div> <?php }
Und hier für die Related Posts:PHP<h2>Related Posts</h2> <!-- "previous page" action --> <a class="prev browse left"></a> <!-- root element for scrollable --> <div class="scrollable" id=chained> <!-- root element for the items --> <div class="items"> <!-- 1-5 --> <div> <!-- Related Posts--> <?php $backup = $post; $tags = wp_get_post_tags($post->ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; $args=array( 'tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'showposts'=>4, // Number of related posts that will be shown. 'caller_get_posts'=>1 ); $my_query = new wp_query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) { $my_query->the_post(); ?> <div class="relatedPosts"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(120,80)); ?></a> <div class="relatedPosts_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div></div> <?php } echo ''; } } $post = $backup; wp_reset_query(); ?> <!-- end Related Posts--> </div> <!-- 10-15 --> <div>Hier meine Webseite.
Wäre toll, wenn mir hier jemand einen Tipp geben könnte, wie ich das am besten anstellen kann.
Vielen Dank im Voraus! :)
-
Hallo.
Ich habe versucht, einen Loop Offset für meine Related Posts zu kreieren.
Die sind bei mir mit einem "Scrollable" Container umhüllt und ich möchte, dass die ersten 4 "Related Posts" angezeigt werden und dass man dann zu den nächsten 4 weiterscrollen kann. Insgesamt 12.Ursprünglich sah das ganze so aus (ohne Offset):
PHP<h2>Related Posts</h2> <!-- "previous page" action --> <a class="prev browse left"></a> <!-- root element for scrollable --> <div class="scrollable" id=chained> <!-- root element for the items --> <div class="items"> <div> <!-- Related Posts--> <?php $backup = $post; $tags = wp_get_post_tags($post->ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; $args=array( 'tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'showposts'=>4, // Number of related posts that will be shown. 'caller_get_posts'=>1 ); $my_query = new wp_query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) { $my_query->the_post(); ?> <div class="relatedPosts"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(120,80)); ?></a> <div class="relatedPosts_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div></div> <?php } echo ''; } } $post = $backup; wp_reset_query(); ?> <!-- end Related Posts--> </div> <div> <!-- Related Posts--> <?php $backup = $post; $tags = wp_get_post_tags($post->ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; $args=array( 'tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'showposts'=>4, // Number of related posts that will be shown. 'caller_get_posts'=>1 ); $my_query = new wp_query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) { $my_query->the_post(); ?> <div class="relatedPosts"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(120,80)); ?></a> <div class="relatedPosts_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div></div> <?php } echo ''; } } $post = $backup; wp_reset_query(); ?> <!-- end Related Posts--> </div>Dann hab ich folgendes versucht:
PHP<h2>Related Posts</h2> <!-- "previous page" action --> <a class="prev browse left"></a> <!-- root element for scrollable --> <div class="scrollable" id=chained> <!-- root element for the items --> <div class="items"> <div> <!-- Related Posts--> <?php $backup = $post; $tags = wp_get_post_tags($post->ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; $args = array( 'tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'posts_per_page'=> 12 ); $my_query = new WP_Query( $args ); if( $my_query->have_posts() ): ?> <div class="relatedPosts"> <?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(120,80)); ?></a> <div class="relatedPosts_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div></div> // if this is not the last post // and remainder of current post plus one then divided by four is zero // close the container and open a new one <?php if( $my_query->current_post != ( $my_query->post_count - 1 ) && ( ( $my_query->current_post + 1 ) % 4 ) == 0 ): ?> </div> <div class="relatedPosts"> <?php endif; endwhile; ?> </div> <?php endif; ?> <?php $post = $backup; wp_reset_query(); ?> <!-- end Related Posts--> </div> </div> </div> <!-- "next page" action --> <a class="next browse right"></a> <br clear="all" /> </div> <div class="postBoxMidInner"> <?php comments_template(); ?> </div> </div> <div class="postBoxBottom"></div> </div> <?php endwhile; else: ?> <p>Sorry, but you are looking for something that isn't here.</p> <?php endif; ?>Leider bekomme ich Syntax-Fehler ("syntax error, unexpected T_ENDWHILE") egal wo und wie viele "closing tags" ich verwende. Ich verzweifle so langsam und hoffe, dass mir jemand weiterhelfen kann und mir meinen Fehler aufzeigen kann.
Vielen lieben Dank im Voraus! :)
-
-
Hallo.
Ich bin neu hier und hoffe wirklich, dass mir hier jemand helfen kann, nach wochenlangem Probieren, Lernen, Lesen, Tutorials etc., habe ich wirklich die Hoffnung aufgegeben.Das Problem ist, dass ich momentan zwei javascripts habe, beide benutzen jquery, die sich scheinbar nicht vertragen.
Das eine ist eine custom.js, die ein Dropdown-Navigationsmenu erstellt.
Das andere ist von meinem Parent Theme übernommen. Es geht um ein eigenes Contact Form. Funktioniert einwandfrei, aber das Ajax funktioniert nicht, wenn ich gleichzeitig auch das custom.js für die Navigation aufrufe.Bisher hatte ich alle scripts in der header.php, das sa wie folgt aus:
PHP<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.form.js"></script> <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/cufon-yui.js"></script> <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/Century_Gothic_400-Century_Gothic_700.font.js"></script> <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/javascript/custom.js"></script>Nun habe ich gelesen, dass es nicht ratsam ist, die Scripts direkt im Header zu laden, also habe ich sie alle rausgenommen und stattdessen versucht, sie in die function.php einzubauen. Das sieht folgendermaßen aus:
PHP
Alles anzeigenfunction my_scripts_method() { // Load jQuery if ( !is_admin() ) { wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"), false); wp_enqueue_script('jquery'); } wp_register_script('custom', get_template_directory_uri() . '/javascript/custom.js', array('jquery')); wp_register_script('cufon-yui', get_template_directory_uri() . '/js/cufon-yui.js', array('jquery')); wp_register_script('century_font', get_template_directory_uri() . '/js/Century_Gothic_400-Century_Gothic_700.font.js', array('jquery', 'cufon-yui')); wp_enqueue_script('custom'); wp_enqueue_script('jquery.form'); wp_enqueue_script('cufon-yui'); wp_enqueue_script('century-font'); } add_action('wp_enqueue_scripts', 'my_scripts_method');Außer der "custom.js" und damit das Navigationsmenü funktioniert GAR NICHTS!
Ich hab auch andere ähnliche Code-Schnipsel ausprobiert, das Ergebnis ist immer das gleiche.
Ich weiß wirklich nicht, was ich falsch mache, aber das "Contact form", das Ajax benutzt und der Font funktionieren nicht.Ich hab wirklich ALLES rauf- und runterprobiert. Ohne Erfolg.
Zur Referenz:
Meine Webseite
custom.js: http://pastebin.com/A9ZRySra
sendmail.php: http://pastebin.com/vq2w1ge3
header.php: http://pastebin.com/NzaPMbbbIch hoffe wirklich, dass mir jemand weiterhelfen kann.
Irgendwas läuft da falsch.Vielen Tausend Dank im Voraus für jegliche Tipps und Hinweise! :)