• Home
  • About
  • Contact
  • Advertise

Devlounge

Design, Develop, and Grow

ateşli sevgilisi fantezisini yaşamak istediğini söyler porno ona arkadaşları varken onunla gizli saklı seks yapmak istediğini sikiş söyleyen kız hafta sonu için gelen arkadaşının görmediği bir sikiş açıdan sakso çekmeye başlayınca adamın yarağını bu altyazılı porno şekilde indiremez ve açık şekilde salonda sikişimeye sex izle başladıklarında misafir kızı da bu sekslerine rokettube konuk ederler seks yapacağını düşünmeyerek onun sex izle oyun oynadığını zanneder sabah olur ve herkes uyanır hd porno bu sırada yanında şişme mankenini de getiren sapık erotik hikayeler genç sınav haftası ders çalışan genç adam üvey annesinin sikiş eve gelmesiyle hayatının şokunu yaşar

  • Home
  • Code
  • Design
  • Design Focus
  • Interviews
  • Publishing
  • Strategy
  • Webapps
  • Extras

Using Filters With Conditional Tags in Child Themes

May 25, 2010 By Remkus de Vries

On a recent project using a Genesis child theme I found myself in a situation where I wanted to use a filter, but only on certain views, namely the category view and the homepage view. Adding a filter is pretty straight forward, but using that filter in combination with conditional tags you need to add a bit extra instead of just the tags themselves.

Now, the example is for the Genesis Framework, but really the logic behind will work on any child theme using filters. What I wanted to filter was the output of the post meta area, which normally displays both the categories and the tags. I wanted to use a slightly different post meta on the homepage where the tags would be replaced with a Continue reading link.

This is what the filter looks like:

[php]//Customizing Post Meta
function forsite_post_meta_filter($post_meta) {
$post_meta = ‘Filed Under: Code, Continue Reading‘;
return $post_meta;
}[/php]

As you can see I am just adding a permalink with a ‘Continue Reading’ text. Nothing too fancy. Normally you would add your filter and you’d be all done. Like so:

[php]//Customizing Post Meta
function forsite_post_meta_filter($post_meta) {
$post_meta = ‘Filed Under: Code, Continue Reading‘;
return $post_meta;
}

add_filter(‘genesis_post_meta’, ‘forsite_post_meta_filter’);[/php]

Using Conditial Tags with this filter actually requires the use of an add_action statement. The way to do is by declaring another function which handles the conditional tags. Something like this

[php]function forsite_post_meta_conditionals() {
if( is_home() || is_category() ) {
add_filter(‘genesis_post_meta’, ‘forsite_post_meta_filter’);
}
}

add_action(‘wp’, ‘forsite_post_meta_conditionals’);[/php]

The if statement determines to actually use this filter only whether you are looking at the home page or the category view. Combined the full code looks like this:

[php]//Customizing Post Meta
function forsite_post_meta_filter($post_meta) {
$post_meta = ‘Filed Under: Code, Continue Reading‘;
return $post_meta;
}
function forsite_post_meta_conditionals() {
if( is_home() || is_category() ) {
add_filter(‘genesis_post_meta’, ‘forsite_post_meta_filter’);
}
}
add_action(‘wp’, ‘forsite_post_meta_conditionals’);[/php]

More info on conditional tags can be found in the Codex, and more information on WordPress filters. Have you worked with conditional tags and / or filters before?

Code & Tutorials

Which Front-End Development Languages Will Grow in 2017?

Your Guide to Leveraging APIs as a Developer

Bitcoin Processing Website Integration For Web Developers

Website Security For 2016 That All Developers Need To Know

5 Reasons You Need to Be Using jQuery

About Devlounge

Want to read more about Devlounge, or maybe you want to contact us, or even advertise? Oh, and don't forget to subscribe to updates!

The Best of Devlounge

Larissa Meek

Search