issue in breadcrumbs of a custom taxonomy - php

I have a custom post type and custom taxonomies. Hierarchy of the pages is like this that first listing page is displayed. In listing page categories are also displayed.
If user is on listing page breadcrumbs is like this. Home/Projects and it is proper and working fine.
If user clicks on some category than breadcrumb is like this . Home/Project/category-1 . I also works fine.
ERROR:
If user clicks on any project than breadcrumb and its links are not proper.
Home/Projects/Projects-Catcategory-1/Al Murabit and its link is also like this.
code
$ref1 = parse_url(wp_get_referer());
if($taxonomy_names[0] )//||is_term()||is_singular())
{
echo '<li>' . $post_type->labels->singular_name . '6</li>';
if(str_replace('/','',str_replace($taxonomy_names[0],'',$ref1['path'])))
{
echo '<li><a href="' . $homeLink . '/' . $taxonomy_names[0] . '/'.
str_replace('/','',str_replace($taxonomy_names[0],'',$ref1['path'])).'">' .
str_replace('/','',str_replace($taxonomy_names[0],'',$ref1['path'])) . '30</a></li>';
}
}

Related

wordpress display categories with image

newbie to writing PHP here. Many hours of searching and don't know if I'm looking in the right places.
I have a custom taxonomy (directory) with custom post categories for the listings.
I am using Advanced Custom Fields to add an image to each custom category (directory-image).
I am currently displaying the custom categories perfectly fine within a custom directory page template using the code below.
$cat = get_query_var('cat'); $args = array(
'orderby' => 'id',
'child_of' => $cat,
'hide_empty' => 0,
'taxonomy' => directory_categories
);
$categories = get_categories($args);
foreach($categories as $category) {
echo '<a href="' . get_category_link( $category->term_id ) . '" class="cat-icon-view">' . "\n";
echo '<img src=" " width="90%" height="164"></img>' . "\n";
echo ' <h5>' . $category->name . '</h5>' . "\n";
echo '</a>' . "\n";
}$
It has space to put the image, however I am not confident at writing php markup to include the image that is outputted from the custom image field under the custom category.
<?php the_field('directory-image', false); ?>
I have read many pages on writing PHP within PHP but I wasn't able to make it work and I'm sure there's a better way: Help!
Write PHP code in PHP
How to write php within html within php?
Display Categories with Image in Multiple Pages of Homepage - Magento
If you already have added a custom image field to category taxonomy, you should access it via tax meta. For the reference use official doc.
foreach ($categories as $category){
$image = get_term_meta($category->term_id, 'directory-image', true);
}

How add link href in product Opencart?

I Beginner for Opencart, I try add some product in my home website.
I check from category/product.php in Store Front, every product have link by category(linkweb/Computer/Notebook/product)
When i check from category.tpl It's use <a href="<?php echo $product['href']; ?>">
In Controller for product :
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'])
But I don't know where the code came from if (isset($this->request->get['path'])) { (already check in view & model)
How i can add request $this->request->get['path'] in my code for make href ??
I would appreciate any answers or comments.
If you want to add particular product(s) into the Home page of your shop, then there is "Featured" module for this purpose. Just add products there and put it into the Home Layout.

Woocommerce Product Navigation should not show next category

I am using woocommerce plugin and i have woocommerce product navigation link plugin to navigate inside products...
I want to have show the product navigation only inside the category.. Currently its is showing navigation to all the products.. i.e., if one category is completed then it is showing the navigation button to the next product in the next category.. here is my Code i have in the woocommerce-product-navigation.php file ..
Here's the Eval
What is the mistake i am doing and i can i get it ?
$output = '<div class="wpn_buttons ' . $wpn_custom_class .'">';
if ( $previous != '' )
$output .= '<span class="next"> ' . $previous . '</span>';
if ( $next != '' )
$output .= ' <span class="previous">' . $next .'</span>';
$output .= '</div>';
I think you should consider the hooks and write some function to filter the contents something like if category is changed exit .I guess you should use woocommerce_before_single_product hook .

Adding class “current_page_item” for custom post type category list(note: the category is belong in custom taxonomy)

I have this code:
<?php
//list terms in a given taxonomy (useful as a widget for twentyten)
$taxonomy = 'advice-cat';
$tax_terms = get_terms($taxonomy);
?>
<ul>
<?php
foreach ($tax_terms as $tax_term) {
echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';
}
?>
</ul>
it display the list of category with permalink. so I want if I click one of the category in the list the list I click must highlight so visitors identify that they are in that specific category.
Have you tried the wp_list_categories() function?
From the Codex: http://codex.wordpress.org/Template_Tags/wp_list_categories
Another option is to run a walker function to ouput a menu:
https://wordpress.stackexchange.com/questions/115526/add-class-to-items-in-wp-list-categories

Wordpress Awesome Filterable portfolio plugin

Currently I'm working on a project which I have installed a Wordpress plugin to the site called 'Awesome Filterable portfolio Plugin'. This is a plugin to show portfolio items in categories.
The plugin is working fine and as aspected. However, my clients wants to show not all portfolio items by default, when going to the portfolio page, but only the three portfolio items from a category; in my case 'visitekaartjes'.
I already raised this question to the plugin developer, but never got a reply back on the Wordpress plugin support page.
My knowledge of PHP is limited, so i'm struggling to get this last item done. But, I have an idea were to look, but even after searching and trial & error for days, it doesn't get to the eureka moment. That's why i'm trying my luck here.
Here's the code:
$items = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'afp_items ORDER BY ' . $orderby);
if( $afpOptions['sort_cat'] == 'on' ){
$orderby = ' ORDER BY cat_name';
} else {
$orderby = '';
}
$cats = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'afp_categories' . $orderby);
?>
<?php
//AFP Main Container
$output='<div class="afp-clear"></div>
<div id="afp-container">';
//Start Echo Categories
$output.='<ul id="afp-filter">
';
foreach ( $cats as $cat ){
$output.='<li>' . $cat->cat_name . '</li>';
}
$output.='</ul>';
//End Echo Categories
//Start Echo Portfolio Items
$output.='<ul class="afp-items">';
$k = 1;
foreach ($items as $item ){
$output.='<li class="afp-single-item" data-id="id-' . $k . '" data-type="' . ereg_replace("[^A-Za-z0-9]", "", $item->item_category) .'">
<a class="fancybox" title="' . $item->item_description . '" href="' . $item->item_image . '"><img alt="" class="img-link-initial" src="' . $item->item_thumbnail . '"></a><br />
<ul class="afp-item-details">';
if($item->item_title != null) { $output.='<li><strong>' . $item->item_title . '</strong></li>'; }
if($item->item_client != null) { $output.='<li>' . $item->item_client . '</li>'; }
if($item->item_date != '0000-00-00') { $output.='<li>' . date("m/d/Y", strtotime($item- >item_date)) . '</li>'; }
if($item->item_link != null) { $output.='<li><a target="_' . $afpOptions['project_link'] . '" href="' . $item->item_link . '">Project Link</a></li>'; }
$output.='</ul>
</li>';
$k++;
}
$output.='</ul>
Hope somebody can help me with this.
Thanks in advanced,
Roland
If you want to allow a visitor to click a button and view more or all items you maybe should implement this clientside using JavaScript & CSS. (Unless you have thousands of items in the portfolio)
You set the height of the container to the height of 1 row of items. And then create a button that will extend this height, to show either one row at a time or to show all items at ones.
I actually implemented this myself on http://annual-insight.nl/referenties/ You can just check this file: http://annual-insight.nl/wp-content/plugins/ai-referenties/js/air-functions.js to see what I did there.
It requires your portfolio items to be of equal height.
Actually, the portfolio is a custom post type and the portfolio category is a custom taxonomy, used to group the portfolio items in categories. In this case, to query a custom post type with custom taxonomy, WordPress provides better and easy solution, for example, to query for three portfolio items with custom taxonomy (portfolio category) design you can write a query like this
$args = array(
'post_type' => 'portfolio',
'posts_per_page' => 3,
'tax_query' => array(
array(
'taxonomy' => 'portfolio_category', // Could be anything in your case
'field' => 'slug',
'terms' => 'design'
)
)
);
$query = new WP_Query( $args );
Now you can loop it like,
if($query->have_posts()): while()
while ($the_query->have_posts()): $query->the_post();
?><h2><?php the_title(); ?></h2><?php
endwhile;
endif;
This may doesn't answer your question but gives you an idea to do it properly.

Categories