A couple days ago I twittered that I’d be share a Dynamic Most Popular Pages By Category Wordpress hack. Et par dager siden jeg twittered at jeg skulle dele en dynamisk mest populære sidene Etter kategori Wordpress skår. Its been in place on this blog for that time and I’ve noticed a decent improvement in the time people are spending on the site and the number of pages they visit. Dens vært på plass på denne bloggen for tiden og jeg har lagt merke til en skikkelig forbedring i tiden folk bruker på nettstedet og antall sider de besøker.

Keep in mind, my increase is also a consequence of my categories being listed at the top of the page. Husk min økningen er også en konsekvens av mine kategorier som er oppført øverst på siden. People click through it often. Folk klikker på den ofte. I use it as a method to filter traffic and get visitors exactly where they want to be. Jeg bruker det som en metode for å filtrere trafikk og få besøkende akkurat der de ønsker å være. Arguably, I need to go through some of my first posts and categorize them better, however, I’m sure many of you find yourself in the same position. Uten tvil, jeg trenger å gå gjennom noen av mine første innlegg og kategorisere dem bedre, men jeg er sikker mange av du finne deg selv i samme posisjon.

Adding a categorical most popular pages on category pages will provide you some relief until you can do that yourself. Legge til en categorical mest populære sidene på kategorien sidene vil gi deg noen lettelse før du kan gjøre det selv. Either way, its still nice to have a another sorting method. Uansett, det er fortsatt hyggelig å ha en annen sortering av metoden. And anything that helps the majority of your visitors improves the bottom line of most website’s goals. Og noe som bidrar til at flertallet av de besøkende forbedrer bunnlinjen på de fleste nettsted mål.

Example Eksempel

Web Design Category Page: http://robmalon.com/category/web-design/ Web Design Kategori Page: http://robmalon.com/category/web-design/

Plugin & Version Requirements Plugin & versjonen krav

Wordpress.Com Stats - Wordpress.Com Stats is one of the best, and the least load intensive statistics tracker you can get for Wordpress. Wordpress.Com Stats - Wordpress.Com Stats er en av de beste og de minst laste intensiv statistikk tracker kan du få for Wordpress. Why? Hvorfor? Because Wordpress themselves hosts it! Ettersom Wordpress seg selv er vert det! See the graph to the right for an example of how it appears in your dashboard. Se på grafen til høyre for et eksempel på hvordan det vises i oversikten. This is where the data is pulled from to create the popular posts list. Denne er der hvor dataene er hentet fra for å lage den populære innleggene listen.

Wordpress Popular Post - This “hack” is actually a modification to the Wordpress Popular Post Plugin . Wordpress Populære - Denne "hacke" er egentlig en modifikasjon til Wordpress Populære Plugin. Perhaps they will update it with this functionality in a future release. Kanskje de vil oppdatere den med denne funksjonaliteten i en fremtidig utgave.

Wordpress 2.6 - I’m using this on a Wordpress 2.6.x install. Wordpress 2.6 - Jeg bruker dette på en Wordpress 2.6.x installere. I’ve heard that the popular post plugin does not work on Wordpress 2.5, but that may be an isolated issue. Jeg har hørt at Populære plugin-modulen virker ikke på Wordpress 2.5, men som kan være en isolert sak. Give it a try and comment your results below. Prøve og kommentere resultatene nedenfor.

WPPP - Wordpress Popular Posts Modifications WPPP - Wordpress populære innlegg modifikasjoner

You can see the code changes below, but here is a link to my wppp.php modifications . Du kan se koden nedenfor, men her er en link til min wppp.php modifikasjoner. I modified the 1.3.4 version of Wordpress Popular Posts. Jeg endret 1.3.4 versjon av Wordpress Populære innlegg. I’ll try and keep this updated, but you may be able to make changes to future versions of the plugin (with my additions) by using something like winmerge to migrate new/old code Jeg vil prøve og holde dette oppdatert, men du kan være i stand til å gjøre endringer i fremtidige versjoner av plugin (med mine filer) ved hjelp av noe sånt som winmerge å overføre nye / gamle koden

The wppp.php file we’re modifying here can be found in: /wp-content/plugins/wordpresscom-popular-posts/wppp.php (if the plugin is installed) Den wppp.php filen vi endrer her finner du i: / wp-content/plugins/wordpresscom-popular-posts/wppp.php (hvis plugin-modulen er installert)

  1. //Make changes to wppp.php version 1.3.4 and in this order for line numbers to be accurate
  2. //LINE 20 - ADD AFTER: ,’title_length’ => ‘0′
  3. , ‘by_category’ => ‘0′
  4. //LINE 61 - REPLACE: $howmany *= 2;
  5. $howmany *= 5 ;
  6. //LINE 87 STARTS WITH: $results = $wpdb->get_results("
  7. //CONTINUES TILL 94 WHICH ENDS WITH: }
  8. REPLACE WITH :
  9. //RobMalon.com category hack
  10. $currentcat = $WPPP_defaults [ ‘by_category’ ] ;
  11. //Checks and toggle default query usage
  12. if ( is_numeric ( $opzioni [ ‘by_category’ ] ) && $opzioni [ ‘by_category’ ] > 0 ) {
  13. $results = $wpdb -> get_results ( "SELECT * FROM {$wpdb->posts} p LEFT OUTER JOIN wp_term_relationships r ON r.object_id = p.ID LEFT OUTER JOIN wp_terms t ON t.term_id = r.term_taxonomy_id WHERE p.id IN (" . implode ( ‘,’ , $id_list ) . ") AND p.post_type = ‘" . ( $opzioni [ ’show’ ] == ‘pages’ ? ‘page’ : ‘post’ ) . "’ AND t.term_id = ‘" . $opzioni [ ‘by_category’ ] . "’" ) ;
  14. } else {
  15. //note ID changed to upper case
  16. $results = $wpdb -> get_results ( "SELECT ID FROM {$wpdb->posts} WHERE id IN (" . implode ( ‘,’ , $id_list ) . ") AND post_type = ‘" . ( $opzioni [ ’show’ ] == ‘pages’ ? ‘page’ : ‘post’ ) . "’" ) ;
  17. }
  18. $valid_list = array ( ) ;
  19. foreach ( $results as $valid ) {
  20. $valid_list [ ] = $valid -> ID ; //note ID changed to upper case
  21. }
  22. //LINE 209 - ADD AFTER: $opzioni['title_length'] = $opzioni['title_length'] !== NULL ? $opzioni['title_length'] : $WPPP_defaults['title_length'];
  23. $opzioni [ ‘by_category’ ] = $opzioni [ ‘by_category’ ] !== NULL ? $opzioni [ ‘by_category’ ] : $WPPP_defaults [ ‘by_category’ ] ; $ $opzioni [ ‘by_category’ ] = $opzioni [ ‘by_category’ ] !== NULL ? $opzioni [ ‘by_category’ ] : $WPPP_defaults [ ‘by_category’ ] ;

Category Template Additions Kategori Template filer

Now you need to add a function call to WPPP_show_popular_posts in your /wp-content/themes/[themename]/category.php file. Nå må du legge til en funksjon kallet til WPPP_show_popular_posts i / wp-content/themes / [themename] / category.php fil. I’ve customized it in such a way that if there are less than 5 posts in a category, that it wont display a the popular category widget. Jeg har tilpasset det slik at hvis det er mindre enn 5 poster i en kategori, at det vilikke vise en den populære kategorien widget. You can see it and easily change that functionality in the code you see below. Du kan se det og enkelt å endre på at funksjonaliteten inn koden du ser nedenfor.

  1. <?php if ( have_posts ( ) ) : ?>
  2. < h1 id = "cat_h1" > Category : <?php single_cat_title ( ) ? ></ h1 >
  3. <?php
  4. $numposts = $wp_query -> post_count ;
  5. if ( function_exists ( ‘WPPP_show_popular_posts’ ) && $numposts >= 5 ) { ?>
  6. < div id = "popularbycategory" >
  7. < h2 style = "padding:0;" > TOP 5 <?php single_cat_title ( ) ?> Articles </ h2 >
  8. < div class = "alreadyread" >
  9. <?php
  10. $category = get_the_category ( ) ;
  11. WPPP_show_popular_posts ( "show=posts&by_category={$category[0]->term_id}&title=&number=5&days=360&format=- <a href=’%post_permalink%’ title=’%post_title_attribute%’>%post_title%</a>" ) ;
  12. ?>
  13. </ div ></ div >
  14. <?php } ?>

General Popular Posts Generelt Populære innlegg

As a quick bonus, I thought I’d also give you the parameters of the general WPPP_show_popular_posts call that I’m using in the top left of all the pages on this site. Som en rask bonus, jeg trodde jeg vil også gi parametere for den generelle WPPP_show_popular_posts samtale som jeg bruker i øvre venstre av alle sidene på dette nettstedet.

  1. <?php if ( function_exists ( ‘WPPP_show_popular_posts’ ) ) WPPP_show_popular_posts ( "show=posts&title_length=45&title=&number=6&days=360&format=- <a href=’%post_permalink%’ title=’%post_title_attribute%’>%post_title%</a>" ) ; ?>

Extending The Idea Utvide tanken

Note that the Popular By Categories hack I created was a rather quick fix. Merk at Populære Ved Kategorier hakke jeg laget var en relativt rask løsning. There’s more than one way to do it, and ways to make it more efficient/extendable. Det er mer enn én måte å gjøre det, og måter å gjøre den mer effektiv / utvides. For example, pulling the popular categories for multiple delimited categories at once. For eksempel trekke populære kategorier for flere avgrensede kategorier samtidig. That would come in handy for a those that assign multiple categories to a post and want to display a “Most Popular Posts Within This Posts Categories”. Som ville komme i hendig for de som tildeler flere kategorier til et innlegg og vil vise en "Mest Populære innlegg i denne Posts kategorier". That’sa mouthful, and something I might do if its requested enough. Det mouthful, og noe jeg kan gjøre hvis de forespurte nok.

Leave a comment below with your results, examples, or questions. Legg igjen en kommentar nedenfor med resultater, eksempler, eller spørsmål.



Leave A Comment: Legg igjen en kommentar:

Comments RSS Feed Kommentarer RSS feed

8 - 3 = 8 - 3 =

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. Tilpasset tema av Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. "));
"));