Can i add new badges ? Like Premium Free Using Custom Fileds or tags?
Featured Badge
16 posts from 5 voices-
Posted 2 years ago #
-
nice idea ;) it would be really great
Posted 2 years ago # -
Hi,
This isn't built into the theme, but with a little customisation you could easily add this. I'll pass this onto Kriesi for an answer as to whether this will make it into an updated version as a new function.
Cheers
Posted 2 years ago # -
Hey guys. Indeed a nice idea, but I am not sure yet if i will add this option since there are too many possibilitys to include them all. I will rather teach you how it is done ;)
first of all you need to creat a new custom field when writing a post. Lets name it "premium" for now. now set the value to "1";
once that is done you need to tell the template file to do something with this value. I will demonstrate it at the example of index.php but you can also might add it to the single.php file, the galler y archive, etc.
in index.php look out for line 30 which should read:
$featured = get_post_meta($post->ID, "_prev_featured", true);
add the following:
$premium = get_post_meta($post->ID, "premium", true); //check if post has a premium mark
now at line 57 you should find this:
if($featured == 'yes') echo "<span class='featured_entry'></span>";
this controlls if the featured_entry badge is shown by adding a span that gets a background image applied within your css files. simply follow it up with:
if($premium == 1) echo "<span class='featured_entry premium'></span>";
last thing to do is to add a new rule to your style.css file at the bottom that overwrites the featured background image that gets applied to the featured_entry class. thats the reason we set an additional premium class:
#top .premium{ background:url("images/skin1/premium.png") no-repeat scroll 0 top transparent; } now you just need to create a badge called premium.png and you are done ;)Posted 2 years ago # -
Awesome trying it now
Working gr8 tyvm
But can i use tag instead of field ?
Posted 2 years ago # -
you can try the following:
instead of
$premium = get_post_meta($post->ID, "premium", true); //check if post has a premium mark
you can try this:
$posttags = get_the_tags(); $premium = $posttags[0]->name;
and instead of this:
if($premium == 1) echo "<span class='featured_entry premium'></span>";
use this:
if($premium == 'tagname') echo "<span class='featured_entry premium'></span>";
of course you need to exchange tagname with the tagname you entered. also this will only work for the first tag applied to the entry
Posted 2 years ago # -
Awesome thanks alot
Posted 2 years ago # -
Hey!
my pleasure ;)
Best regards,
KriesiPosted 2 years ago # -
Excellent tutorial Kriesi, thanks.
If I want to add more custom fields like this , it does not work.
What sould I do ?Posted 2 years ago # -
Hey,
did you use another name for your second custom field - so instead of "premium" use something else like "special" and adjust the code above (by replacing the word premium with special)Posted 2 years ago # -
Hey Dude,
of course...I want to add joomla,magento and drupal badge.
Posted 2 years ago # -
Can you create me an admin account and send me the login details to: kriesi2000-dude@yahoo.com - I'll have a look into it.
Posted 2 years ago # -
danke Peter, habe gerade account hinzugefügt.
Du hast schon bestimmt E-mail gekriegt....Posted 2 years ago # -
Ok it works now.
Just call your post meta field wordpress, drupal, etc. and set the value to 1.
I've set a drupal "featured badge".
Posted 2 years ago # -
danke Peter.Du bist great Supporter!
Posted 2 years ago # -
Froh, dass ich helfen konnte :)
Posted 2 years ago #
Reply
You must log in to post.














