does someone know how to change an image header dynamically depends by specific categories,
ex: image1 for red category, image2 for blue category, image3 for green category?
Im using ultimate member plugin but don't well php coding
I have found the original code
function um_profile_header_cover_area( $args ) {
global $ultimatemember;
if ( $args['cover_enabled'] == 1 ) {
$default_cover = um_get_option('default_cover');
$overlay = '<span class="um-cover-overlay">
<span class="um-cover-overlay-s">
<ins>
<i class="um-faicon-picture-o"></i>
<span class="um-cover-overlay-t">'.__('Change your cover photo', 'ultimatemember').'</span>
</ins>
</span>
</span>';
?>
<div class="um-cover <?php if ( um_profile('cover_photo') || ( $default_cover && $default_cover['url'] ) ) echo 'has-cover'; ?>" data-user_id="<?php echo um_profile_id(); ?>" data-ratio="<?php echo $args['cover_ratio']; ?>">
<?php do_action('um_cover_area_content', um_profile_id() ); ?>
<?php
if ( $ultimatemember->fields->editing ) {
$items = array(
''.__('Change cover photo', 'ultimatemember').'',
''.__('Remove', 'ultimatemember').'',
''.__('Cancel', 'ultimatemember').'',
);
echo $ultimatemember->menu->new_ui( 'bc', 'div.um-cover', 'click', $items );
}
?>
<?php $ultimatemember->fields->add_hidden_field( 'cover_photo' ); ?>
<?php echo $overlay; ?>
<div class="um-cover-e">
<?php if ( um_profile('cover_photo') ) { ?>
<?php
if( $ultimatemember->mobile->isMobile() ) {
if ( $ultimatemember->mobile->isTablet() ) {
echo um_user('cover_photo', 1000);
echo um_user('cover_photo', 300);
}
} else {
echo um_user('cover_photo', 1000);
}
?>
<?php } elseif ( $default_cover && $default_cover['url'] ) {
$default_cover = $default_cover['url'];
echo '<img src="'. $default_cover . '" alt="" />';
} else {
if ( !isset( $ultimatemember->user->cannot_edit ) ) { ?>
<span class="um-cover-add-i"><i class="um-icon-plus um-tip-n" title="<?php _e('Upload a cover photo', 'ultimatemember'); ?>"></i></span>
<?php }
} ?>
</div></div>
<?php
}}
Thanks in advance
Related
i've created a colophon for my website in which i post all the logos of the different sponsors i have. I add all the sponsors via custom post type. i also added a specific custom taxonomy to distinguish between the different typologies of sponsorships.
I use this code in the footer.php to display them:
<?php $terms = get_terms('sponsor_tipology');
$count = count( $terms );
if ( $count > 0 ) {
foreach ( $terms as $term ) { ?>
<div class="col-xs-12 <?php echo $term->slug ;?>">
<h3><?php echo $term->name;?></h3>
<?php $arg = array (
'post_type' => 'colophone',
'post_per_page' => -1,
'sponsor_edition' => 'current',
'sponsor_tipology' => $term->slug,
);
$pesca_post = new WP_Query ($arg);
$quanti_post = $pesca_post->post_count;
if(have_posts()){
while ($pesca_post->have_posts()) : $pesca_post->the_post();
$featured = get_the_post_thumbnail_url(get_the_ID(),'large');
if ($quanti_post == 5){
$classe_bootstrap = 15;
}elseif ($quanti_post > 5){
$classe_bootstrap = "2 text-center";
}elseif($quanti_post < 5){
$classe_bootstrap = 12/$quanti_post;
}
echo '<div class="col-md-' . $classe_bootstrap . '">';
if (isset($featured)){
$img = $featured;
}else{
$img = get_template_directory_uri() . '/img/placeholder.png';
} ?>
<a href="<?php echo esc_attr(get_permalink($msd_settings['partner_page'])); ?>" title="<?php echo get_the_title($post->ID);?>" >
<div class="col-xs-12" style="background-image:url(<?php echo esc_url($img); ?>); height:100px;background-size:contain;background-repeat:no-repeat;background-position:center center;"></div>
</a>
<?php echo '</div>';
endwhile;
}?>
</div>
<?php }
}?>
my problem is that this code is completely working just on some pages, on other it shows the contents avoiding the ones belonging to the first term, no matter which it will be.
I have noticed that it works in pagaes where i use other queries.
What am i doing wrong?
i changed it in this way and now it's working!
$terms = get_terms('sponsor_tipology');
$count = count( $terms );
if ( $count > 0 ) {
foreach ( $terms as $term ) { //per ogni termine presente
$nome = $term->slug;?>
<div class="col-xs-12 <?php echo $term->slug ;?>">
<h3><?php echo $term->name;?></h3>
<?php $arg = array (
'post_type' => 'colophone',
'post_per_page' => -1,
'sponsor_edition' => 'current',
'sponsor_tipology' => $nome,
);
$elementi = get_posts($arg);
$quanti_post = count( $elementi );
if ($quanti_post == 5){
$classe_bootstrap = 15;
}
elseif ($quanti_post > 5){
$classe_bootstrap = "2 text-center";
}
elseif($quanti_post < 5){
$classe_bootstrap = 12/$quanti_post;
}
foreach($elementi as $elemento){
$featured = get_the_post_thumbnail_url($elemento->ID,'large');
if (isset($featured)){
$img = $featured;
}
else{
$img = get_template_directory_uri() . '/img/placeholder.png';
} ?>
<div class="col-md-<?php echo $classe_bootstrap; ?>">
<a href="<?php echo esc_attr(get_permalink($msd_settings['partner_page'])); ?>" title="<?php echo get_the_title($elemento->ID);?>" >
<div class="col-xs-12" style="background-image:url(<?php echo esc_url($img); ?>); height:100px;background-size:contain;background-repeat:no-repeat;background-position:center center;"></div>
</a>
</div>
<?php }?>
</div>
<?php }
}?>
I have a code in PHP that displays icons of social medias. But when the user didn't fill them, they don't show up. Which is great but I would like to encourage them to fill it up with a text/link.
Here is the code :
<?php
add_filter( "buddyboss_get_user_social_array", "buddyboss_user_social_remove_disabled" ); //remove disabled.
//Allow users to display their social media links in their profiles.
$profile_social_media_links_switch = boss_get_option( 'profile_social_media_links_switch' );
if ( ! empty( $profile_social_media_links_switch ) ):
$social_profiles = (array)boss_get_option( 'profile_social_media_links' );
foreach ( $social_profiles as $social ):
if ( empty( $social['title'] ) ) {
continue;
}
$social_key = sanitize_title( $social['title'] );
$background_image_style = '';
$icon_url = $social['thumb'];
$url = buddyboss_get_user_social( bp_displayed_user_id(), $social_key ); //Get user social link
//Set profile icon
if ( ! empty ( $icon_url) ) {
$background_image_style = "background-image: url($icon_url); background-size: cover;";
}
?>
<?php if ( !empty( $url ) ): ?>
<a class="btn" href="<?php echo $url; ?>" title="<?php echo esc_attr( $social['title'] ); ?>" target="_blank"><i style="<?php echo $background_image_style ?>" class="alt-social-icon alt-<?php echo empty( $background_image_style ) ? $social_key : ''; ?>"></i> </a>
<?php endif; ?>
<?php endforeach;
endif;
?>
</div>
How to add this text : Display your Social Profiles here...
If I caught the main goal, it is necessary to display the text Display your Social Profiles here... in case of no social_profiles.
I check on empty both $profile_social_media_links_switch and $social_profiles. If any of them is empty then show your desired text
Try this code:
<?php
add_filter( "buddyboss_get_user_social_array", "buddyboss_user_social_remove_disabled" ); //remove disabled.
//Allow users to display their social media links in their profiles.
$profile_social_media_links_switch = boss_get_option( 'profile_social_media_links_switch' );
if ( ! empty( $profile_social_media_links_switch ) ) {
$social_profiles = (array)boss_get_option('profile_social_media_links');
if (!empty($social_profiles)) {
foreach ($social_profiles as $social) {
if (empty($social['title'])) {
continue;
}
$social_key = sanitize_title($social['title']);
$background_image_style = '';
$icon_url = $social['thumb'];
$url = buddyboss_get_user_social(bp_displayed_user_id(), $social_key); //Get user social link
//Set profile icon
if (!empty ($icon_url)) {
$background_image_style = "background-image: url($icon_url); background-size: cover;";
}
if (!empty($url)) { ?>
<a class="btn" href="<?php echo $url; ?>" title="<?php echo esc_attr($social['title']); ?>"
target="_blank"><i
style="<?php echo $background_image_style ?>"
class="alt-social-icon alt-<?php echo empty($background_image_style) ? $social_key : ''; ?>"></i>
</a>
<?php
}
}
} else {
echo 'Display your Social Profiles here...';
}
} else {
echo 'Display your Social Profiles here...';
}
?>
</div>
I have a table with a row called lugar that have the value 1 or 2.
When I do foreach, i want to filter the elements that have the value 1 in the row lugar and the elements that have the value 2.
$descuento->lugar is the variable for the row lugar.
Actually, my code is:
<ul id="slider">
<?php foreach ( $results['descuentos'] as $descuento ) {
$titulo = htmlspecialchars( $descuento->title );
$title_url = limpiarCaracteresEspeciales($titulo);
?>
<li>
<?php if ( $imagePath = $descuento->getImagePath( IMG_TYPE_FULLSIZE ) ) { ?>
<img src="<?php echo $imagePath?>" alt="<?php echo htmlspecialchars( $descuento->title )?>" />
<?php } else {?> <img src="http://lorempixel.com/400/300/sports/" alt="<?php echo htmlspecialchars( $descuento->title )?>" /> <?php } ?>
<div>
<strong><span><?php echo htmlspecialchars( $descuento->title )?></span></strong>
<p><?php echo $descuento->content ?></p>
</div>
</li>
<?php
}
?>
</ul>
Then you could try this:
foreach ( $results['descuentos'] as $descuento )
{
if( $descuento->lugar == 1)
{
$titulo = htmlspecialchars( $descuento->title );
$title_url = limpiarCaracteresEspeciales($titulo);
echo '<li>';
if ( $imagePath = $descuento->getImagePath( IMG_TYPE_FULLSIZE ) )
{
echo '<img src="'. $imagePath. '" alt="'. $titulo. '" />';
}
else
{
echo '<img src="http://lorempixel.com/400/300/sports/" alt="'. $titulo. '" />';
}
echo '<div>'.
'<strong><span>'. $titulo. '</span></strong>'.
'<p>'. $descuento->content. '</p>'.
'</div>'.
'</li>';
}
}
I am trying to make changes to a site that is in Wordpress and the widget that I thing have the info I want to change a blank. I found the footer.php code in the editor put need help where the copyright text is. Where the code says ($data['copyright_text']), where do I find the copyright text?
<?php
global $data;
?>
<?php
if ( empty( $data['footer_show'] ) || (!empty( $data['footer_show'] ) && $data['footer_show'] == 'yes') ) { ?>
<footer id="footer">
<div class="container">
<?php
if ( !empty ( $data['footer_row1_widget_positions'] ) ) {
if ( (!empty ( $data['footer_row1_show'] ) && $data['footer_row1_show'] == 'yes' ) || empty ( $data['footer_row1_show'] ) ) {
echo '<div class="row">';
$number_of_columns = key( json_decode ( stripslashes ( $data['footer_row1_widget_positions'] ) ) );
$columns_array = json_decode ( stripslashes ( $data['footer_row1_widget_positions'] ),true );
for ($i = 1; $i <= $number_of_columns; $i++) {
echo '<div class="span'.$columns_array[$number_of_columns][0][$i-1].'">';
if ( !dynamic_sidebar('Footer row 1 - widget '.$i.'') ) : endif;
echo '</div>';
}
echo '</div><!-- end row -->';
}
}
if ( !empty ( $data['footer_row2_widget_positions'] ) ) {
if ( (!empty ( $data['footer_row2_show'] ) && $data['footer_row2_show'] == 'yes' ) || empty ( $data['footer_row2_show'] ) ) {
echo '<div class="row">';
$number_of_columns = key( json_decode ( stripslashes ( $data['footer_row2_widget_positions'] ) ) );
$columns_array = json_decode ( stripslashes ( $data['footer_row2_widget_positions'] ),true );
for ($i = 1; $i <= $number_of_columns; $i++) {
echo '<div class="span'.$columns_array[$number_of_columns][0][$i-1].'">';
if ( !dynamic_sidebar('Footer row 2 - widget '.$i.'') ) : endif;
echo '</div>';
}
echo '</div><!-- end row -->';
}
}
?>
<div class="row">
<div class="span12">
<div class="bottom fixclear">
<?php
if ( isset( $data['footer_social_icons'] ) && is_array( $data['footer_social_icons'] ) && !empty ( $data['footer_social_icons'][0]['footer_social_icon'] ) ) {
$icon_class = '';
if( $data['footer_which_icons_set'] == 'colored' ) {
$icon_class = 'colored';
}
echo '<ul class="social-icons '.$icon_class.' fixclear">';
echo '<li class="title">'.__('GET SOCIAL', THEMENAME ).'</li>'; // Translate
foreach ( $data['footer_social_icons'] as $key=>$icon ){
$link = '';
$target = '';
if ( isset ( $icon['footer_social_link'] ) && is_array ( $icon['footer_social_link'] )) {
$link = $icon['footer_social_link']['url'];
$target = 'target="'.$icon['footer_social_link']['target'].'"';
}
echo '<li class="'.$icon['footer_social_icon'].'"><a href="" '.$target.'>'.$icon['footer_social_title'].'</a></li>';
}
echo '</ul>';
}
?>
<?php if( $data['copyright_text'] || $data['footer_logo'] ) { ?>
<div class="copyright">
<?php
if( $data['footer_logo'] ) {
echo '<img src="'.$data['footer_logo'].'" alt="" />';
}
if( $data['copyright_text'] ) {
echo '<p>'.stripslashes($data['copyright_text']).'</p>';
}
?>
</div><!-- end copyright -->
<?php } ?>
</div><!-- end bottom -->
</div>
</div><!-- end row -->
</div>
</footer>
<?php } ?>
</div><!-- end page_wrapper -->
<?php echo __('TOP', THEMENAME ); ?> <?php // Translate ?>
<?php wp_footer(); ?>
</body>
</html>
If you just want to see what the current copyright text is, you can stick echo $data['copyright_text']; anywhere after declaring global $data;.
To delete it, you can do $data['copyright_text'] = null; or $data['copyright_text'] = '';
Be careful of changing your theme like this. If you have a theme that has a commercial License, you may get into trouble for removing the Licencees copyright and trademark.
If you've created the theme yourself however, then it should be placed in the footer file in a place that is appropriate to the design of the theme.
Im working with a Wordpress theme.
The code I am having trouble with is relevant to a filter divided into "action" and "categories".
I would like to have 2 checkboxes checked by default (1 action & 1 category) and the rest blank.
I'm at a complete loss, any help would be sincerely appreciated.
here is the code:
<?php
$icons = array();
$taxonomy = 'property_action_category';
$tax_terms = get_terms($taxonomy);
$taxonomy_cat = 'property_category';
$categories = get_terms($taxonomy_cat);
// add only actions
foreach ($tax_terms as $tax_term) {
$icon_name = 'wp_estate_icon'.$tax_term->slug;
$icons[$tax_term->slug] = esc_html( get_option($icon_name) );
}
// add only categories
foreach ($categories as $categ) {
$icon_name = 'wp_estate_icon'.$categ->slug;
$icons[$categ->slug] = esc_html( get_option($icon_name) );
}
?>
<div class="gmap_wrapper <?php
if (!is_front_page()) {
print 'gmap_not_home" style="height:295px;"';
}else{
print'"';
}
?>>
<div class="gmap-next <?php if (is_front_page()) print 'is-front'; ?>" id="gmap-next" > </div>
<div class="gmap-prev <?php if (is_front_page()) print 'is-front'; ?>" id="gmap-prev" > </div>
<?php
$geo_status = esc_html ( get_option('wp_estate_geolocation','') );
$custom_image = esc_html( esc_html(get_post_meta($post->ID, 'page_custom_image', true)) );
$rev_slider = esc_html( esc_html(get_post_meta($post->ID, 'rev_slider', true)) );
if($geo_status=='yes' && $custom_image=='' && $rev_slider==''){
print' <div id="mobile-geolocation-button"></div>';
}
?>
<div id="googleMap" <?php
$home_small_map_status= esc_html ( get_option('wp_estate_home_small_map','') );
if (!is_front_page() || ( is_front_page() && $home_small_map_status=='yes' ) ) {
print 'style="height:295px;"';
}
?>
</div>
<div class="tooltip"> <?php _e('click to enable zoom','wpestate');?></div>
<div id="gmap-loading"><?php _e('Loading Maps','wpestate');?>
<span class="gmap-animation">
<img src="<?php print get_template_directory_uri();
?>
</span>
</div>
<?php
////////////////////////// enable /disable map filters
$show_filter_map_status = esc_html ( get_option('wp_estate_show_filter_map','') );
$home_small_map_status = esc_html ( get_option('wp_estate_home_small_map','') );
if($show_filter_map_status!='no'){
?>
<div class="gmap-menu-wrapper" >
<div class="gmap-menu" id="gmap-menu" <?php if (!is_front_page() || (is_front_page() && $home_small_map_status=='yes') ) print 'style="display:none;"'; ?> >
<div id="closefilters"></div>
<div class="action_filter" >
<?php
foreach ($tax_terms as $tax_term) {
print '<div class="checker"><input type="checkbox" checked="checked" name="filter_action[]" id="'.$tax_term->slug.'" class="'.$tax_term- >slug.'" value="'.$tax_term->name.'"/><label for="'.$tax_term->slug.'"><span></span>';
if( $icons[$tax_term->slug]!='' ){
print '<img src="'.$icons[$tax_term->slug].'" alt="'.$tax_term->name.'">' . $tax_term->name . '</label></div>';
}else{
print '<img src="'.get_template_directory_uri().'/css/css- images/'.$tax_term->slug.'icon.png" alt="'.$tax_term->name.'">' . $tax_term->name . '</label></div>';
}
}
?>
</div>
<div class="type-filters">
<?php
foreach ($categories as $categ) {
print '<div class="checker"><input type="checkbox" checked="checked" name="filter_type[]" id="'.$categ->slug.'" class="' . $categ->slug . '" value="' . $categ->name . '"/><label for="' . $categ->slug. '"><span></span>';
if( $icons[$categ->slug]!='' ){
print' <img src="'.$icons[$categ->slug].'" alt="'.$categ->slug.'">' . $categ->name . '</label></div>';
}else{
print' <img src="'.get_template_directory_uri().'/css/css-images/'.$categ->slug.'icon.png" alt="'.$categ->name.'">' . $categ->name . '</label></div>';
}
}
?>
</div>
</div>
</div>
<?php
}
?>
</div> `enter code here`
Thanks
Kyle