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

Similar option in Settings as Simplicity in Peddlar (Woothemes) WordPress

  • SOLVED

Hello,

Would like the Display Title option (true/false) on Peddlar similar to Simplicity on the Featured Slider Settings.

Don't want to just hide using css.

Added to theme-options.php on Peddlar - shows up in Peddlar Settings - done.

$options[] = array( "name" => __( 'Show Title with Image Background', 'woothemes' ),
"desc" => __( 'Show the post title when using an image as slider background.', 'woothemes' ),
"id" => $shortname."_slider_title",
"std" => "false",
"type" => "checkbox");


Next, need code to add to the featured-slider.php in Peddlar
Current code in Peddlar:
/* Retrieve the settings and setup query arguments. */
$settings = array(
'featured_entries' => '3',
'featured_order' => 'DESC',
'featured_slide_group' => '0',
'featured_videotitle' => 'true',
);

$settings = woo_get_dynamic_values( $settings );

$query_args = array(
'limit' => $settings['featured_entries'],
'order' => $settings['featured_order'],
'term' => $settings['featured_slide_group']
);

/* Retrieve the slides, based on the query arguments. */
$slides = woo_featured_slider_get_slides( $query_args );


/* Media settings */
$media_settings = array( 'width' => '1024', 'height' => '768' );

if ( 'true' != $settings['featured_videotitle'] ) {
$media_settings['width'] = '1024';
$media_settings['height'] = '768';
}

/* Begin HTML output. */
if ( false != $slides ) {
$count = 0;

$container_css_class = 'flexslider';

if ( 'true' == $settings['featured_videotitle'] ) {
$container_css_class .= ' default-width-slide';
} else {
$container_css_class .= ' full-width-slide';
}
?>
<div id="featured-slider" class="flexslider <?php echo esc_attr( $container_css_class ); ?>">
<ul class="slides">
<?php
foreach ( $slides as $k => $post ) {
setup_postdata( $post );
$count++;

$url = get_post_meta( get_the_ID(), 'url', true );
$layout = get_post_meta( get_the_ID(), '_layout', true );
$title = get_the_title();
if ( $url != '' ) {
$title = '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $title ) . '">' . $title . '</a>';
}

$css_class = 'slide-number-' . esc_attr( $count );

$slide_media = '';
$embed = woo_embed( 'width=' . intval( $media_settings['width'] ) . '&height=' . intval( $media_settings['height'] ) . '&class=slide-video' );
if ( '' != $embed ) {
$css_class .= ' has-video';
$slide_media = $embed;
} else {
$image = woo_image( 'width=1024&noheight=true&class=slide-image&link=img&return=true' );
if ( '' != $image ) {
$css_class .= ' has-image no-video';
$slide_media = $image;
} else {
$css_class .= ' no-image';
}
}
if ( $layout ) {
$css_class .= ' ' . $layout;
}
?>
<li class="slide <?php echo esc_attr( $css_class ); ?>">
<?php
if ( '' != $slide_media ) {
echo '<div class="slide-media">' . $slide_media . '</div><!--/.slide-media-->' . "\n";
}
?>
<?php if ( '' == $embed || ( '' != $embed && 'true' == $settings['featured_videotitle'] ) ) { ?>
<div class="slide-content">
<?php if ( $title) : ?>
<header><h1><?php echo $title; ?></h1></header>
<?php endif; ?>
<?php if ( get_the_content() != '' ) { ?>
<div class="entry"><?php the_content(); ?></div><!--/.entry-->
<?php } ?>
</div><!--/.slide-content-->
<?php } ?>
</li>
<?php } wp_reset_postdata(); ?>
</ul>
</div><!--/#featured-slider-->


---
Thank you!

Answers (1)

2013-06-21

Expert answers:

Can you paste the existing code for featured-slider.php in Peddlar. OR if you can send me the files from both the themes I can help you.


Creativira comments:

theme-actions.php from Simplicity; Peddlar above

/*-----------------------------------------------------------------------------------*/
/* Featured Slider Settings */
/*-----------------------------------------------------------------------------------*/

add_filter('woo_head', 'woo_slider_options');
function woo_slider_options() {

global $woo_options;

if ( isset( $woo_options['woo_slider'] ) && $woo_options['woo_slider'] == 'true' && ( is_home() || is_front_page() ) && ! is_paged() ) { ?>

<script type="text/javascript">
jQuery( window ).load(function(){
if ( jQuery( 'body.home #slides .slide' ).length > 1 ) {
jQuery( 'body.home #slides' ).slides({
preload: true,
preloadImage: '<?php echo get_template_directory_uri(); ?>/images/loading.png',
autoHeight: true,
effect: '<?php echo $woo_options['woo_slider_effect']; ?>',
container: 'slides_container',
<?php if ( isset( $woo_options['woo_slider_random'] ) && $woo_options['woo_slider_random'] == 'true' ): ?>
randomize: true,
<?php endif; ?>
<?php if ( isset( $woo_options['woo_slider_hover'] ) && $woo_options['woo_slider_hover'] == 'true' ): ?>
hoverPause: true,
pause: 4000,
<?php endif; ?>
<?php if ( isset( $woo_options['woo_slider_auto'] ) && $woo_options['woo_slider_auto'] == 'true' ): ?>
play: <?php echo $woo_options['woo_slider_interval'] * 1000; ?>,
<?php endif; ?>
slideSpeed: <?php echo $woo_options['woo_slider_speed'] * 1000; ?>,
fadeSpeed: <?php echo $woo_options['woo_fade_speed'] * 1000; ?>,
<?php if ( isset( $woo_options['woo_slider_nextprev'] ) && $woo_options['woo_slider_nextprev'] == 'true' ): ?>
generateNextPrev: true,
<?php endif; ?>
generatePagination: false,
<?php if ( isset( $woo_options['woo_slider_crossfade'] ) && $woo_options['woo_slider_crossfade'] == 'true' ): ?>
crossfade: true
<?php else: ?>
crossfade: false
<?php endif; ?>
});
} else {
jQuery( 'body.home #slides .slides_container .slide' ).fadeIn();
}

});
</script>

<?php } // End IF Statement

}


Creativira comments:

featured.php for Simplicity

<?php
global $woo_options; $count = 0;

$args = array( 'suppress_filters' => false, 'post_type' => 'slide' );

if ( isset( $woo_options['woo_slider_entries'] ) ) {
$args['numberposts'] = intval( $woo_options['woo_slider_entries'] );
} else {
$args['numberposts'] = 3;
}

if ( isset( $woo_options['woo_featured_slide_group'] ) && ( 0 < intval( $woo_options['woo_featured_slide_group'] ) ) ) {
$args['tax_query'] = array(
array( 'taxonomy' => 'slide-page', 'field' => 'id', 'terms' => intval( $woo_options['woo_featured_slide_group'] ) )
);
}
?>
<div id="slides">
<div id="slide-box">
<?php $slides = get_posts( $args ); ?>
<?php if ( ! empty( $slides ) ) : ?>
<div class="slides_container col-full">
<?php foreach( $slides as $post ) : setup_postdata( $post ); $count++; ?>

<div class="slide slide-<?php echo $count; ?>" <?php if( $woo_options['woo_slider_entries'] == 1 ) { echo 'style="display:block;"'; }?>>
<?php
$url = get_post_meta( $post->ID, 'url', true );
$slide_content_class = 'entry';
$has_video = get_post_meta( $post->ID, 'embed', true );
$has_image = get_post_meta( $post->ID, 'image', true );
$post_thumb = get_option('woo_post_image_support') == 'true' && has_post_thumbnail();
$title = $woo_options['woo_slider_title'] == 'true';
$content = $woo_options['woo_slider_content'] == 'true';
?>
<?php if ( $has_video ) { $slide_content_class = 'video'; } ?>

<?php if ( $has_video || $has_image || $post_thumb ) { ?>
<?php if ( $title || $content ) { ?>
<div class="slide-content <?php echo $slide_content_class; ?> fl">

<?php if ( $title ) { ?><h2 class="title"><a href="<?php if ( $url ) { echo $url; } else { echo '#'; } ?>"><?php the_title(); ?></a></h2><?php } ?>

<?php if ( $content ) { ?><?php the_content(); ?><?php } ?>

</div><!-- /.slide-content -->
<?php } ?>

<?php if ( $has_image || $post_thumb ) { ?>
<div class="slide-image fl">
<?php if ( $url ) { ?>
<a href="<?php echo $url; ?>" title="<?php the_title(); ?>"><?php woo_image('key=image&width=960&height=338&class=slide-img&link=img'); ?></a>
<?php } else { ?>
<?php woo_image('key=image&width=960&height=338&class=slide-img&link=img'); } ?>
</div><!-- /.slide-image -->

<?php } elseif ( $has_video ) {

echo woo_embed('key=embed&width=500&class=video');

} ?>

<div class="fix"></div>

<?php } else { ?><!-- // End $type IF Statement -->

<div class="entry">
<?php the_content(); ?>
</div>

<?php } ?>

</div><!-- /.slide -->

<?php endforeach; ?>

</div><!-- /.slides_container -->
<?php endif; ?>

</div><!-- /#slide-box -->
<?php if ( isset( $woo_options['woo_slider_pagination'] ) && ( $woo_options['woo_slider_pagination'] == 'true' ) && $count > 1 ) { ?>
<div id="slider_nav">
<div id="slider_pag">
<ul class="pagination">
<?php
for ( $i = 0; $i < $count; $i++ ) {
?>
<li><a href="#<?php echo $i; ?>"><?php echo $i + 1; ?></a></li>
<?php
}
?>
</ul><!--/.pagination-->
</div><!--/#slider_pag-->
</div><!--/#slider_nav-->
<?php } ?>
</div><!-- /#slides -->


Expert comments:

featured-slider.php in Peddlar: (keep a backup of this file and replace the below code.

<?php
/* Retrieve the settings and setup query arguments. */
$settings = array(
'featured_entries' => '3',
'featured_order' => 'DESC',
'featured_slide_group' => '0',
'featured_videotitle' => 'true',
'featured_slide_title' => 'true',
);

$settings = woo_get_dynamic_values( $settings );
$query_args = array(
'limit' => $settings['featured_entries'],
'order' => $settings['featured_order'],
'term' => $settings['featured_slide_group']
);

/* Retrieve the slides, based on the query arguments. */
$slides = woo_featured_slider_get_slides( $query_args );

/* Media settings */
$media_settings = array( 'width' => '1024', 'height' => '768' );
if ( 'true' != $settings['featured_videotitle'] )
{
$media_settings['width'] = '1024';
$media_settings['height'] = '768';
}

/* Begin HTML output. */
if (false != $slides) {
$count = 0;
$container_css_class = 'flexslider';
if ( 'true' == $settings['featured_videotitle'] )
{
$container_css_class .= ' default-width-slide';
}
else
{
$container_css_class .= ' full-width-slide';
}
?>
<div id="featured-slider" class="flexslider <?php echo esc_attr( $container_css_class ); ?>">
<ul class="slides">
<?php
foreach ( $slides as $k => $post )
{
setup_postdata( $post );
$count++;
$url = get_post_meta( get_the_ID(), 'url', true );
$layout = get_post_meta( get_the_ID(), '_layout', true );
$title = get_the_title();
if ( $url != '' )
{

if ( 'true' == $settings['featured_slide_title'] )
{
$title = '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $title ) . '">' . $title . '</a>';
}
else
{
$title = '';
}
}
$css_class = 'slide-number-' . esc_attr( $count );
$slide_media = '';
$embed = woo_embed( 'width=' . intval( $media_settings['width'] ) . '&height=' . intval( $media_settings['height'] ) . '&class=slide-video' );
if ( '' != $embed )
{
$css_class .= ' has-video';
$slide_media = $embed;
}
else
{
$image = woo_image( 'width=1024&noheight=true&class=slide-image&link=img&return=true' );
if ( '' != $image )
{
$css_class .= ' has-image no-video';
$slide_media = $image;
}
else
{
$css_class .= ' no-image';
}
}
if ( $layout )
{
$css_class .= ' ' . $layout;
}
?>
<li class="slide <?php echo esc_attr( $css_class ); ?>">
<?php
if ( '' != $slide_media )
{
echo '<div class="slide-media">' . $slide_media . '</div><!--/.slide-media-->' . "\n";
}
?>
<?php if ( '' == $embed || ( '' != $embed && 'true' == $settings['featured_videotitle'] ) )
{ ?>
<div class="slide-content">
<?php if ( $title ) : ?>
<header><h1><?php echo $title; ?></h1></header>
<?php endif; ?>
<?php if ( get_the_content() != '' )
{ ?>
<div class="entry"><?php the_content(); ?></div><!--/.entry-->
<?php } ?>
</div><!--/.slide-content-->
<?php } ?>
</li>
<?php }
wp_reset_postdata(); ?>
</ul>
</div><!--/#featured-slider-->



Expert comments:

I am not able to edit my previous answer. As you have changed the settings option to slider_title, pls consider the below answer.

<?php
/* Retrieve the settings and setup query arguments. */
$settings = array(
'featured_entries' => '3',
'featured_order' => 'DESC',
'featured_slide_group' => '0',
'featured_videotitle' => 'true',
'slider_title' => 'true',
);

$settings = woo_get_dynamic_values( $settings );
$query_args = array(
'limit' => $settings['featured_entries'],
'order' => $settings['featured_order'],
'term' => $settings['featured_slide_group']
);

/* Retrieve the slides, based on the query arguments. */
$slides = woo_featured_slider_get_slides( $query_args );

/* Media settings */
$media_settings = array( 'width' => '1024', 'height' => '768' );
if ( 'true' != $settings['featured_videotitle'] )
{
$media_settings['width'] = '1024';
$media_settings['height'] = '768';
}

/* Begin HTML output. */
if (false != $slides) {
$count = 0;
$container_css_class = 'flexslider';
if ( 'true' == $settings['featured_videotitle'] )
{
$container_css_class .= ' default-width-slide';
}
else
{
$container_css_class .= ' full-width-slide';
}
?>
<div id="featured-slider" class="flexslider <?php echo esc_attr( $container_css_class ); ?>">
<ul class="slides">
<?php
foreach ( $slides as $k => $post )
{
setup_postdata( $post );
$count++;
$url = get_post_meta( get_the_ID(), 'url', true );
$layout = get_post_meta( get_the_ID(), '_layout', true );
$title = get_the_title();
if ( $url != '' )
{

if ( 'true' == $settings['slider_title'] )
{
$title = '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $title ) . '">' . $title . '</a>';
}
else
{
$title = '';
}
}
$css_class = 'slide-number-' . esc_attr( $count );
$slide_media = '';
$embed = woo_embed( 'width=' . intval( $media_settings['width'] ) . '&height=' . intval( $media_settings['height'] ) . '&class=slide-video' );
if ( '' != $embed )
{
$css_class .= ' has-video';
$slide_media = $embed;
}
else
{
$image = woo_image( 'width=1024&noheight=true&class=slide-image&link=img&return=true' );
if ( '' != $image )
{
$css_class .= ' has-image no-video';
$slide_media = $image;
}
else
{
$css_class .= ' no-image';
}
}
if ( $layout )
{
$css_class .= ' ' . $layout;
}
?>
<li class="slide <?php echo esc_attr( $css_class ); ?>">
<?php
if ( '' != $slide_media )
{
echo '<div class="slide-media">' . $slide_media . '</div><!--/.slide-media-->' . "\n";
}
?>
<?php if ( '' == $embed || ( '' != $embed && 'true' == $settings['featured_videotitle'] ) )
{ ?>
<div class="slide-content">
<?php if ( $title ) : ?>
<header><h1><?php echo $title; ?></h1></header>
<?php endif; ?>
<?php if ( get_the_content() != '' )
{ ?>
<div class="entry"><?php the_content(); ?></div><!--/.entry-->
<?php } ?>
</div><!--/.slide-content-->
<?php } ?>
</li>
<?php }
wp_reset_postdata(); ?>
</ul>
</div><!--/#featured-slider-->


Creativira comments:

Thank you, Subharanjan. It is still showing the title.


Expert comments:

<?php
/* Retrieve the settings and setup query arguments. */
$settings = array(
'featured_entries' => '3',
'featured_order' => 'DESC',
'featured_slide_group' => '0',
'featured_videotitle' => 'true',
'slider_title' => 'false'
);

$settings = woo_get_dynamic_values( $settings );
$query_args = array(
'limit' => $settings['featured_entries'],
'order' => $settings['featured_order'],
'term' => $settings['featured_slide_group']
);

/* Retrieve the slides, based on the query arguments. */
$slides = woo_featured_slider_get_slides( $query_args );

/* Media settings */
$media_settings = array( 'width' => '1024', 'height' => '768' );
if ( 'true' != $settings['featured_videotitle'] )
{
$media_settings['width'] = '1024';
$media_settings['height'] = '768';
}

/* Begin HTML output. */
if (false != $slides) {
$count = 0;
$container_css_class = 'flexslider';
if ( 'true' == $settings['featured_videotitle'] )
{
$container_css_class .= ' default-width-slide';
}
else
{
$container_css_class .= ' full-width-slide';
}
?>
<div id="featured-slider" class="flexslider <?php echo esc_attr( $container_css_class ); ?>">
<ul class="slides">
<?php
foreach ( $slides as $k => $post )
{
setup_postdata( $post );
$count++;
$url = get_post_meta( get_the_ID(), 'url', true );
$layout = get_post_meta( get_the_ID(), '_layout', true );
$title = get_the_title();
if ( $url != '' )
{

if ( 'true' == $settings['slider_title'] )
{
$title = '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $title ) . '">' . $title . '</a>';
}
else
{
$title = '';
}
}
$css_class = 'slide-number-' . esc_attr( $count );
$slide_media = '';
$embed = woo_embed( 'width=' . intval( $media_settings['width'] ) . '&height=' . intval( $media_settings['height'] ) . '&class=slide-video' );
if ( '' != $embed )
{
$css_class .= ' has-video';
$slide_media = $embed;
}
else
{
$image = woo_image( 'width=1024&noheight=true&class=slide-image&link=img&return=true' );
if ( '' != $image )
{
$css_class .= ' has-image no-video';
$slide_media = $image;
}
else
{
$css_class .= ' no-image';
}
}
if ( $layout )
{
$css_class .= ' ' . $layout;
}
?>
<li class="slide <?php echo esc_attr( $css_class ); ?>">
<?php
if ( '' != $slide_media )
{
echo '<div class="slide-media">' . $slide_media . '</div><!--/.slide-media-->' . "\n";
}
?>
<?php if ( '' == $embed || ( '' != $embed && 'true' == $settings['featured_videotitle'] ) )
{ ?>
<div class="slide-content">
<?php if ( $title ) : ?>
<header><h1><?php echo $title; ?></h1></header>
<?php endif; ?>
<?php if ( get_the_content() != '' )
{ ?>
<div class="entry"><?php the_content(); ?></div><!--/.entry-->
<?php } ?>
</div><!--/.slide-content-->
<?php } ?>
</li>
<?php }
wp_reset_postdata(); ?>
</ul>
</div><!--/#featured-slider-->



I am assuming that: you have already done this and values are being stored(check/uncheck) properly.

$options[] = array( "name" => __( 'Show Title with Image Background', 'woothemes' ),

"desc" => __( 'Show the post title when using an image as slider background.', 'woothemes' ),

"id" => $shortname."_slider_title",

"std" => "false",

"type" => "checkbox");


Expert comments:

Can you message me access details to codebase ?


Creativira comments:

Yes, I have. Access details sent.


Expert comments:

It works now. Please check.


Expert comments:

Small change in file: featured-slider.php

// if individual slide link is present
if ( $url != '' ) {
if ( 'true' == $settings['slider_title'] ) {
$title = '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $title ) . '">' . $title . '</a>';
} else {
$title = '';
}
}
else {
//if there is no url inserted for that slide to link
$url = '#';
if ( 'true' == $settings['slider_title'] ) {
$title = '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $title ) . '">' . $title . '</a>';
} else {
$title = '';
}
}


Creativira comments:

Got it. Thank you!