I posted a comment on Dates on Blog Posts - Should You Have Them? last week over at Problogger.Net on how easy it would be to implement code to a theme which would allow a user to show or hide content based on the date or age of a post. I opublikował komentarz na temat terminów Blog - Czy je posiadasz? Ciągu ostatnich tygodni na Problogger.Net, w jaki sposób byłoby łatwe do wykonania kodu do tematu, które pozwalają użytkownikowi pokazać lub ukryć treści w oparciu o datę lub wiek z post.I’ve since gotten a few emails about this in particular and was going to share this with some of these tricks I had mentioned when I did the redesign of this site last week . Ja już od zdobyły kilka e-maili na ten temat w szczególności i trafia do akcji w tym niektóre z tych sztuczek miałem kiedy nie wymienione w niniejszej redesign witryny w zeszłym tygodniu.
Dates on Recent Posts But Not on Older Ones - I saw one blogger do this last year (I’m afraid I don’t remember who it was).Ostatnie posty na terminy, ale nie w starszych - Widziałem Jeden z blogowiczów to zrobić w ubiegłym roku (ja jestem boi nie pamiętam którzy go było).They had hacked WordPress so that dates appeared on recent posts (within the last 3 months) but anything older than that did not have time stamps either on the post or comments. Mieli posiekany WordPress tak, że terminy się na najnowszych postów (w ciągu ostatnich 3 miesięcy), ale coś starsze niż że nie miał czasu znaczków albo na posterunku lub komentarze.This meant that the blogger benefited from new posts looking new and took the potential distraction of old posts away from readers. Oznaczało to, że blogger skorzystały z nowych stanowisk szukasz nowych możliwości i miały rozpraszać starych postów od czytelników.I don’t know exactly how the blogger did it but presume they set up a rule that looked at the date of authorship and then determined whether the date would be displayed or not. Nie wiem dokładnie, jak Blogger, ale nie zakładają one ustanowić zasadę, że spojrzał na datę autorstwa a następnie ustalić, czy termin zostanie wyświetlony, czy nie.
In short, to do this you’ll be modifying your theme (/wp-content/themes/YOURTHEME/ index.php and/or single.php) rather then the core wordpress code. W skrócie, to będziesz modyfikowania swój temat (/ wp-content/themes/YOURTHEME / index.php i / lub single.php), a następnie rdzeń WordPress kod.Also I’m using wordpress 2.6 but this should work on anything wordpress 2.0 or later for sure. Także ja jestem przy pomocy WordPress 2,6 ale ten powinien działać na coś wordpress 2,0 lub później na pewno.Anything lower it might work but you might need to redefine $postdate with whatever the_date() function was back then. Wszystko może obniżyć pracy, ale może pojawić się konieczność ponownego $ późniejsze niezależnie the_date () funkcja została następnie z powrotem.(It may very well be the same). (Może on być bardzo dobrze te same).Other then that, its good old PHP that handles it. Inne następnie, że jego starych, dobrych PHP, który obsługuje.
<?php<? php
//File: /wp-content/themes/YOURTHEME/ index.php and/or single.php/ / File: / wp-content/themes/YOURTHEME / index.php i / lub single.php
//Insert HTML code here for data you want to show if the post is newer (within 20 days old of posting)/ / Wstaw kod HTML tutaj dane, które chcesz pokazać, jeśli post jest nowszy (do 20 dni starego delegowania)
<?php}?><? php)?>
//notice the greater than/less than sign flipped/ / zwróć uwagę na większy niż / mniej niż podpisania odwrót
This code must be placed within the loop. Ten kod musi być umieszczony w pętli.By that I mean, it needs to be within that if (have_posts())… bit as shown in the code. Do tego mam na myśli, należy w tym if (have_posts ())… bitowe, jak pokazano w kodzie.From there we’re grabbing the date using the_date(). Stamtąd mamy datę za pomocą obrazu i dźwięku the_date ().You don’t have to use a separate variable for this, but I find it easier because I reference that variable more than once in the code. Nie trzeba korzystać z osobnego dla tej zmiennej, ale łatwiej bo zmiennej referencyjnej, że więcej niż jeden raz w kodzie.
Some Uses For Showing & Hiding ContentNiektóre z zastosowań, dla Wyświetlono & Ukrywanie treści Among the uses that users have for this kind of implementation: Wśród zastosowań, że użytkownicy mają do tego rodzaju realizacji:
AdSense or other Ads - Showing or hiding Ads on pages only after a certain date.AdSense lub inne reklamy - Pokazywanie lub ukrywanie reklam na stronach dopiero po określonej dacie.Readers that keep up with your blog and look at all your new posts right away will appreciate this. Czytelnicy, aby nadążać za swoim blogu i spojrzeć na wszystkie nowe posty od razu będą wdzięczni.They are also your most loyal readers Są one również najbardziej lojalnych czytelników
Social media tags - I’m doing this right now on this site.Social media tagów - Ja robię to prawo już na tej stronie.If the post is older than 20 days, I have it set to display social bookmarking links at the bottom of the post. Jeśli post jest starsze niż 20 dni, mam go ustawić, aby wyświetlić społecznej zakładka linki na dole postu.If its newer, the bar displays at the top. Jeżeli jego nowszą, na pasku u góry.
Contests - If you have different content you want to display before or after a contest, you can use this method to automate the content switch for you.Konkursy - Jeśli masz inną treść, którą chcesz wyświetlić, przed lub po konkursie, możesz użyć tej metody do automatycznego przełączania treści dla Ciebie.For example. Na przykład.Before the contest you could wrap in your form code. Do konkursu można zawijać w swojej formie kodu.After the contest date(s) end you could wrap in a “sorry, this contest is over” text. Po konkursie Data (-y) koniec można zawijać w "Przepraszamy, ten konkurs jest ponad" tekstem.
ResourcesZasoby Template Tags/the date - Wordpress Codex - This is for modifying and understanding the_date() parameters in wordpress’s function.Szablon Tagi / data - Kodeks Wordpress - To jest dla modyfikowania i zrozumienia the_date () parametry wordpress funkcję. http://us3.php.net/manual/en/function.mktime.php - This is the function we’re using within the date() function to “generate” a time.http://us3.php.net/manual/en/function.mktime.php - Jest to funkcja używamy w terminie () funkcja "wygenerować".Note this time is based on your server time. Uwaga: w tym czasie opiera się na serwerze.Which means if your server time is an hour behind you, you can adjust for that by doing something like this (still assuming the two month string). date(”Ymd”,mktime(date(”h”) 1,0,0,date(”m”)-2,date(”d”),date(”Y”))); . Oznacza jeśli serwer czasu jest tyle godzin, możesz dostosować do tego by robić coś takiego (zakładając, że jeszcze dwa miesiące ciąg). Daty ( "Ymd", mktime (date ( "h") 1,0, 0, date ( "m") -2, datę ( "d"), date ( "Y ")));. http://us3.php.net/manual/en/function.date.php - Date function calls/formatting in PHP.http://us3.php.net/manual/en/function.date.php - Termin wywołania funkcji / formatowanie w PHP.If you want to change the format of the date, this would be a good place to go. Jeśli chcesz zmienić format daty, byłoby to dobre miejsce do zrobienia.Just replace the configuration of the Ymd I have in there now to whatever format you want based on the chart shown there. Wystarczy zastąpić układ Ymd Mam tam teraz, aby niezależnie od formatu chcesz oparte na wykresie podana.
Hope that helps! Hope that helps!Questions about this, post below. Pytania na ten temat, post poniżej.New requests or questions about the way I created this theme please post to the Rob Malon redesigned post . Nowe wnioski lub pytania dotyczące sposobu tworzenia tego tematu proszę umieszczać na Rob Malon przebudowa post.
"Display And Hide Content Based On Date Or Age Of Posts - Wordpress Hack""Ukryj wyświetlacz i treści opartej na wiek lub data stanowisk - Wordpress Hack"
Rob, great post. Rob, wielki post.Thanks for the detailed info. Dzięki za szczegółowe informacje.You can never have too many WordPress theme hacks in your arsenal. Możesz nie mieć zbyt wiele WordPress Temat hacks w swoim arsenałem.
46 plugins uploaded for wordpress now - about 30 of them active... 46 wordpress szpunt przesłane do teraz - około 30 z nich aktywnych ...I dont have an addiction problem at all. I dont mieć problemu narkomanii w ogóle.
Website Changes That Improve Bounce Rate And Time On Site http://tinyurl.com/5jfov3 Witryna zmiany zwiększą odrzuceń i czas On Site http://tinyurl.com/5jfov3
@problogger Sure, take a look at mine :) http://www.robmalon.com @ ProBlogger Oczywiście, spójrz na moje:) http://www.robmalon.com
Streaming live with @toddrecommends - http://toddrecommends.tv/live Streaming na żywo z @ toddrecommends - http://toddrecommends.tv/live
eAccelerator - for http://www.openx.org which I hope to use more often now & develop a mod. eAccelerator - http://www.openx.org, które mam nadzieję, że do korzystania z coraz częściej i teraz opracować sposób.400k ad requests a day would kill my box w/o it. 400k reklamy wniosków dziennie to zabije moje pole w / o niej.
I thought I would try to break things today. Myślałam, że będę starać się objawiać się dziś.Actually did a successful install of eAccelerator on my server. Właściwie nie udanej instalacji eAccelerator na moim serwerze.Sites appear to be quicker :) Lokacje wydają się być szybsza:)
@JohnChowDotCom How many readers WITHOUT aweber ;) @ JohnChowDotCom Jak wielu czytelników BEZ aweber;)
Rob, wielki post. Dzięki za szczegółowe informacje. Możesz nie mieć zbyt wiele WordPress Temat hacks w swoim arsenałem.
Wielka informacji