Ask your WordPress questions! Pay money and get answers fast! (more info)

Shopp custom category widgets WordPress

  • SOLVED

Hello
I need to use custom widgets for Shopp Categories. I tried using <strong>Widget Logic</strong> plugin but it doesn't work. Also tried registering custom widgets and modifying sidebar.php with some code like this
<?php if ( is_front_page() ) { ?>
<div id="sidebar">
<?php dynamic_sidebar('Barra de color'); ?>
<?php dynamic_sidebar('Sidebar'); ?>
</div> <!-- end #sidebar -->
<? } elseif ( is_shopp_taxonomy('2') ) { ?>
<div id="sidebar">
<div class="widget">
<?php dynamic_sidebar('Sillas'); ?>
<?php dynamic_sidebar('Categorias'); ?>
<?php dynamic_sidebar('Barra de color'); ?>
</div>
</div> <!-- end #sidebar -->
<? } else { ?>
<div id="sidebar">
<div class="widget">
<?php dynamic_sidebar('Categorias'); ?>
<?php dynamic_sidebar('Barra de color'); ?>
<?php dynamic_sidebar('Sidebar'); ?>
</div>
</div> <!-- end #sidebar -->
<? } ?>

I need a custom function or any other way to add widgets that only show in specific Shopp categories
Thanks
Ciro

Answers (2)

2013-08-02

Sabby Sam answers:

You can try this plugin too
Unlimited Page Sidebars


Ciro Urdaneta comments:

No, it doesn't work. Only shows additional sidebars for post and pages not for Shopp virtual pages


Sabby Sam comments:

I guess this would help you

<?php is_page($page); ?>

http://codex.wordpress.org/Function_Reference/is_page

is_page();
// When any single Page is being displayed.

is_page(42);
// When Page 42 (ID) is being displayed.

is_page('Contact');
// When the Page with a post_title of "Contact" is being displayed.

is_page('about-me');
// When the Page with a post_name (slug) of "about-me" is being displayed.

is_page(array(42,'about-me','Contact'));
// Returns true when the Pages displayed is either post ID 42, or post_name "about-me", or post_title "Contact". Note: the array ability was added at Version 2.5.


Sabby Sam comments:

Do the following steps
1. Register a new sidebar widget using function.php
register_sidebar(array(
'name' => __( 'Shopp' ),
'id' => 'right-sidebar',
'description' => __( 'Widgets in this area will be shown on the right-hand side.' ),
'before_title' => '<h1>',
'after_title' => '</h1>'
));

2. use this in your sidebar
<?php dynamic_sidebar('Shopp'); ?>

3. if above works perfect then add the sidebar login where you want to display
http://codex.wordpress.org/Function_Reference/is_page

It should work. If still it doesn't work then you need to tell us :
Are you using any themes which are created in other theme folder.
Or
please provide us website url and credential details if you can.
Hope this will be easiest way to help you.


Ciro Urdaneta comments:

Hi Sabby Sam
No, it doesn't work. Also the right way is this
<?php dynamic_sidebar('is_shopp_page()'); ?>
And that way the sidebar will show on all the Shopp catalog pages
I need different widgets in different Shopp categories
Regards
Ciro


Sabby Sam comments:

So I think this will help you

Allows you to determine whether or not you are in a page template or if a specific page template is being used.

is_page_template()
Is a Page Template being used?
is_page_template( 'about.php' )
Is Page Template 'about' being used? Note that unlike with other conditionals, if you want to specify a particular Page Template, you need to use the filename, such as about.php or my_page_template.php.
A Category Page
is_category()
When any Category archive page is being displayed.
is_category( '9' )
When the archive page for Category 9 is being displayed.
is_category( 'Stinky Cheeses' )
When the archive page for the Category with Name "Stinky Cheeses" is being displayed.
is_category( 'blue-cheese' )
When the archive page for the Category with Category Slug "blue-cheese" is being displayed.
is_category( array( 9, 'blue-cheese', 'Stinky Cheeses' ) )
Returns true when the category of posts being displayed is either term_ID 9, or slug "blue-cheese", or name "Stinky Cheeses".
in_category( '5' )
Returns true if the current post is in the specified category id. read more
in_category( array( 1,2,3 ) )
Returns true if the current post is in either category 1, 2, or 3.
! in_category( array( 4,5,6 ) )
Returns true if the current post is NOT in either category 4, 5, or 6. Note the ! at the beginning.
Note: Be sure to check your spelling when testing, "is" and "in" are a big difference.


Sabby Sam comments:

And also this could be help you

http://optimizemyshopp.com/blog/how-to-use-widget-logic-with-shopp/
if(is_category( '9' ) && is_shopp_product()) {
// load your content
}

I hope this will get help you.


Ciro Urdaneta comments:

No it doesn't work
Shop categories are NOT the same as WordPress


Sabby Sam comments:

Please provide some login details or something I can see the structure. I hope I can resolve your issue.


Ciro Urdaneta comments:

You can check the online development version here
http://dkm.iws.com.ve


Sabby Sam comments:

Try this

$get_the_cat=$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

/* you can view what you are getting in variable $get_the_cat
/* print_r($get_the_cat);
$result_cat=explode("/",$get_the_cat);
/* check where array index you are getting category
/* echo $result_cat[0]; check till $result_cat[3];

Try this code
if($result_cat[2]=="Sillas") { /* plz check the array index eg $result_cat[1] it will check is the current page is Sillas category
?>

<div id="sidebar">

<div class="widget">

<?php dynamic_sidebar('Sillas'); ?>
</div>
</div>
<?php

}
?>
/* you can do for other category as well.



I hope this will help you. This time I am 100% sure.


Ciro Urdaneta comments:

Hi Sabby Sam

I tried using your code in sidebar.php but it doesn't work. Should be this one?
?php

$get_the_cat=$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$result_cat=explode("/",$get_the_cat);

if($result_cat[2]=="Sillas") {

?>

<div id="sidebar">
<div class="widget">
<?php dynamic_sidebar('Sillas'); ?>
</div>
</div>
<?php } ?>


You can check this answer for another Shopp question, maybe could help
http://wpquestions.com/question/show/id/3641


Sabby Sam comments:

Hi
Did you checked what is the value of result_cat[2]
First check what value you are getting
and also try with this result_cat[1].

This should 100% work.


Ciro Urdaneta comments:

No it doesn't work, returns an empty value
Shopp categories are not related with WordPress categories. You can check it at the page footer, this is the code I added
<p>I should see the cat here <strong><?php
$get_the_cat=$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
print_r($get_the_cat);
?>
</strong></p>

http://dkm.iws.com.ve/


Sabby Sam comments:

Visit here
http://dkm.iws.com.ve/sillas/

it returns some values

explode it
using explode funtion
$result_cat=explode("/",$get_the_cat);
print_r($result_cat);


Sabby Sam comments:

There is nothing related with wordpress here.

It simply calculate is this page is particular category using your address bar ( URL)

We are checking if this page is sillas.

We get the full url of the current page and extract with the "/ ", and check in array.

if you get the value sillas then you can use conditional tag.

Lets get have live chat.

2013-08-02

Hariprasad Vijayan answers:

Hi Ciro,

Have you added the specific widget to widget area from wordpress dashboard?


Ciro Urdaneta comments:

Sure, I did it


Hariprasad Vijayan comments:

Is other widgets displaying properly in sidebar of that particular page?