This is how I can get list of all tld (domain) prices:
{foreach from=$tldpricelist item=tldprice}
TLD: {$tldprice.tld} - Price: {$tldprice.register}
{/foreach}
Hoever I would like to display prices only for certain tlds which I hold in array:
{$pricelist=["co.uk","me.uk","org.uk","uk","london","com","info","net","biz","org","name","eu"]}
I'm very new to SMARTY and I'm sure there should be some simple way of calling $tldpricelist only for certain tlds.
try with in_array fucntion. I added a check in your code. If tld will be in your $pricelist array then it will show TLD and prices otherwise not.
{$pricelist=["co.uk","me.uk","org.uk","uk","london","com","info","net","biz","org","name","eu"]}
{foreach from=$tldpricelist item=tldprice}
{if in_array($tldprice.tld,$pricelist}
TLD: {$tldprice.tld} - Price: {$tldprice.register}
{/if}
{/foreach}
Related
I am making some modifications in the way that customers explore products in a new page .tpl by overriding category
Is there a function that works but gets products from a defined category using a category ID (rather than the current category) ?
I would like to display products from a specific category
When I put this code, it shows me all the products.
{foreach from=$products item=product name=products}
{$product.name|escape:'htmlall':'UTF-8'}
{/foreach}
I am using PS version 1.7.8.6
Try this into tpl
{php}
$category = new Category($id_category_you_chose);
$products = $category->getProducts($this->context->language->id);
{/php}
see the getProducts arguments, i don't remember exactly what he need.
I have a custom post type called 'listing' and a custom taxonomy called 'listing-category'
I am trying to create a class for the single-listing.php posts that is the slug of the parent custom taxonomy only eg:
STAY
- Hotel
- B&B
EAT
- Cafes
- Bakery
SHOP
- Food
- Shoes
So for single posts under hotel - I need to create a class of 'stay' as all posts under that class will have the same style.
What I hope to output is for example:
<div id="main-content" class="stay">
This previous question seems closest but I can't seem to get it working for my project: https://wordpress.stackexchange.com/questions/24794/get-the-the-top-level-parent-of-a-custom-taxonomy-term
I've been going around in circles for about two days with this so any help would be really appreciated!
Actually that answer you have given the link to is OK and solves your problem as well. May be you do wrong implementation.
Here is sample code for your case:
global $post;
$ctp_listing_cats=wp_get_post_terms( $post->ID, 'listing-category' );
if (!empty($ctp_listing_cats[0]->term_id)){
$topparent=get_term_top_most_parent($ctp_listing_cats[0]->term_id,'listing-category');
}
//...
echo '<div id="main-content" class="'.$topparent->name.'">';
get_term_top_most_parent() function of the given code is the function from another answer you gave link to.
It would be better to add one more parameter to wp_get_post_terms,
When you set 'parent' => 0 and it return only parents.
For example:
$company_locations = wp_get_post_terms( $car_id, 'location', array('parent' => 0) );
Has anyone figured out a simple/quick way to use a custom post sort order with Ghost?
Specifically I would like to implement a theme that uses Ghost's tag-{slug}.hbs functionality to render tag specific pages that order posts oldest>newest instead of the default newest>oldest.
Any ideas vs. hacking at ghost core and making a big mess?
Thanks
See : https://github.com/TryGhost/Ghost/issues/5602,
To order post oldest > newest, edit the core\server\models\post.js file, find the orderDefaultOptions function and change the published_at value ('ASC') :
orderDefaultOptions: function orderDefaultOptions() {
return {
status: 'ASC',
published_at: 'ASC',
updated_at: 'DESC',
id: 'DESC'
};
},
You can not make the blog engine return a different sort order. But what you can do is use template code to throw away the results provided by the engine and make it fetch new results with the #get helper.
{{#has any="tag.feature_image"}}
{{#get "posts" filter="tags.slug:{{tag.slug}}" limit=100 order="published_at asc"}}
<!-- `posts` from the parent context is overwritten by get -->
{> "loop"}}
{{/get}}
{{else}}
<!-- default loop -->
{{> "loop"}}
{{/has}}
I for example wanted to list posts in tag.hbs in chronological order if the Tag had a featured_image. So for such tags I use the #get helper to get the posts in chronological order (order="published_at asc"). If not the posts already provided by the blogging engine in reverse order are displayed.
add this line
"postinstall": "sed -i \"s/published_at: 'DESC'/published_at: 'ASC'/g\" node_modules/ghost/core/server/models/post.js && sed -i \"s/_at DESC,'/_at ASC,'/g\" node_modules/ghost/core/server/models/post.js",
inside scripts section in your package.json it should work
I am using wordpress 3.5. I create a custom post type and a custom metabox where i use a html multi select menu
<select data-placeholder="Choose available colors..." class="chosen_multi" name="available_colors[]" id="available_colors" multiple="multiple">
....
....
</select>
i use bellow code to save select value
update_post_meta($id, 'available_colors', strip_tags($_POST['available_colors']));
But i know it not store multi value as array in Database.
How i store array (available_colors[]) by update_post_meta, Not want to use php implode explode
If you store an array with update_post_meta, get_post_meta will return an array. It's that simple.
However, if $_POST['available_colors'] is an array, you can't use strip_tags on it. Instead you would have to use strip_tags on every element:
update_post_meta($id, 'available_colors', array_map( 'strip_tags', $_POST['available_colors'] ) );
I have a website (located here) and I would like to do something to improve the way people search and view different reviews.
I have thought about introducing a way to search through posts based on rating. I currently have one category which has custom field with the field title "Rating". Each value in the custom field is an integer from 1 to 5.
Here's the test category (http://enoda.co.uk/category/ipad-2/ipad-reviews/ipad-utilities/)
I was wanting to know how I would go about introducing a drop down menu somewhere above the posts in the category with star ratings from 1 up to 5. Further, I would like it to take users to reviews with that rating.
Any help would be great,
Best regards,
Jack
Jack,
This is a somewhat complex issue as there are a number of areas within your WP installation that you need address to solve your problem. I'll point you in the right direction, but I don't anticipate that this will be the full answer for you.
First of all, the dropdown. Since you know that you want nothing more that a dropdown that displays choice of rating, you can easily hard code this. Since it is in a custom field, controlled by you, that only you/your colleagues set, you will know what is in that field and can feel safe hard coding this. Alternatively, I would have set up rating as a custom taxonomy with the terms '1 Star', '2 Stars', etc. and then you could build your drop down dynamically from this taxonomy. But, since it's in a custom field, I would just use something like this:
<form action="rating-search.php" method="GET">
<select name="rating-search" id="rating-search">
<option value="1">1 Star</option>
<option value="2">2 Stars</option>
<option value="3">3 Stars</option>
<option value="4">4 Stars</option>
<option value="5">5 Stars</option>
</select>
<input id="rating-search-submit" name="rating-search-submit" value="Search" />
</form>
Now, I'll assume that you can handle the submission of this data. On the page that receives this data (you can accomplish this with a template page), you will need to modify the wp_query to search only for posts that have a meta value of rating = {input value}. You will need code similar to:
$query = new WP_Query();
$query->query(
array(
'meta_query' => array(
array(
'key' => 'rating', // Insert the name of the meta key here
'value' => $_POST['rating-search'], // This is the rating you are matching
'compare' => '=',
'type' => 'NUMERIC'
)
)
)
);
if($query->have_posts())
{
while($query->have_posts())
{
$query->the_post();
global $post;
//Do normal loop business here
}
}
That query will help you search for posts that have the custom field set to the desired value. Note that the meta_query parameter only works for WP 3.1 and higher. It's a super powerful feature and worth updating to 3.1 alone. More about what you can do with the WP_Query class can be found here: http://codex.wordpress.org/Function_Reference/WP_Query.
I know you can't just copy and paste this code to get what you want, but I hope this gives you some ideas of what you can do to get closer to your desired result. Good luck!