How to change the logo of a child page on Wordpress - wordpress

Header.php
<div class="site-branding">
<div class="container">
<?php
***if ( is_page('/category/fitness/') ) ?>{
<img src="<?php bloginfo('template_url'); ?> /assets/images/fitnesslogo.jpg"
width="100" height="100"/>
}***
<?php
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
if ( is_front_page() && is_home() ) : ?>
<h1 class="site-title"><a href="<?php echo esc_url(
home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?>
<p class="site-title"><a href="<?php echo esc_url( home_url(
'/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php
endif;
$description = get_bloginfo( 'description', 'display' );
if ( $description || is_customize_preview() ) : ?>
<p class="site-description"><?php echo $description; /*
WPCS: xss ok. */ ?></p>
<?php
endif; ?>
<?php do_action('boston_after_site_description'); ?>
</div>
</div><!-- .site-branding -->
The page slug is /category/fitness as the URL on the end of the page suggests when I go to the page it looks like it's not interpreting the img src, but is displaying '{}' tags that are around the img scr instead

You have:
***if ( is_page('/category/fitness/') ) ?>{
<img src="<?php bloginfo('template_url'); ?> /assets/images/fitnesslogo.jpg"
width="100" height="100"/>
}***
But it should be
if ( is_page('/category/fitness/') ) {
echo '<img src="'.bloginfo('template_url').'/assets/images/fitnesslogo.jpg" width="100" height="100"/>';
}

I'm not familiar with the Boston theme, but it looks like it's checking to see if a custom logo has been added and if so to use it. So, I would think the following would give you what you're looking for.
<?php if ( is_page('/category/fitness/') ) : ?>
<img src="<?php bloginfo('template_url'); ?>/assets/images/fitnesslogo.jpg" width="100" height="100"/>
<?php else : ?>
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}

Related

Problem with displaying wooccomerce related products

Bello my singleproduct.php, but my related products not shown on all categories, some work and some no, it is depend on query and fonts. For example here is work https://avestone.ru/product-category/nashi-raboti/, but if I change name of category it will not work. And it does not work at all at any russian named category.
<?php
/**
* The Template for displaying all single products
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce\Templates
* #version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header(); ?>
<div class="popup_form" id="popup_form_product">
<div class="popup_form_content" id="popup_form_content_product">
<a href="javascript:PopUpHide()" class="popup_close">
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M17.1875 4.8125L4.8125 17.1875" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M17.1875 17.1875L4.8125 4.8125" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</a>
<div class="form_title">Заказать расчет</div>
<?php echo do_shortcode( '[contact-form-7 id="6241" title="Попап товары"]' ); ?>
</div>
</div>
<?php
/**
* woocommerce_before_main_content hook.
*
* #hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* #hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<div id="product-<?php the_ID(); ?>" <?php wc_product_class( '', $product ); ?>>
<div class="product_content">
<div class="breadcrumb">
<?php $values = get_the_terms( $product->id, 'pa_brend'); ?>
<ul>
<li>Каталог</li>
<li> - </li>
<li>
<?php foreach ( $values as $value ) {
echo '' . $value->name .'';
} ?></li>
<li> - </li>
<li><?php the_title(); ?></li>
</ul>
</div>
<?php the_title( '<h1 class="product_title mobile-product_title">', '</h1>' ); ?>
<?php while ( have_posts() ) : ?>
<?php the_post(); ?>
<div class="product_top_content">
<div class="product_top_content_block">
<div class="product_img">
<?php
$columns = apply_filters( 'woocommerce_product_thumbnails_columns', 4 );
$post_thumbnail_id = $product->get_image_id();
$wrapper_classes = apply_filters(
'woocommerce_single_product_image_gallery_classes',
array(
'woocommerce-product-gallery',
'woocommerce-product-gallery--' . ( $post_thumbnail_id ? 'with-images' : 'without-images' ),
'woocommerce-product-gallery--columns-' . absint( $columns ),
'images',
)
);
?>
<div class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $wrapper_classes ) ) ); ?>" data-columns="<?php echo esc_attr( $columns ); ?>" style="opacity: 0; transition: opacity .25s ease-in-out;">
<figure class="woocommerce-product-gallery__wrapper">
<?php
if ( $post_thumbnail_id ) {
$html = wc_get_gallery_image_html( $post_thumbnail_id, true );
} else {
$html = '<div class="woocommerce-product-gallery__image--placeholder">';
$html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src( 'woocommerce_single' ) ), esc_html__( 'Awaiting product image', 'woocommerce' ) );
$html .= '</div>';
}
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $post_thumbnail_id ); // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped
do_action( 'woocommerce_product_thumbnails' );
?>
</figure>
</div>
</div>
</div>
<div class="product_top_content_block product_top_content_block_right">
<?php the_title( '<h1 class="product_title">', '</h1>' ); ?>
<ul class="product_atr">
<li>Категория: <?php $cats_arr = wc_get_product_category_list( $product->get_id()); $cat_arr = explode(",", $cats_arr); echo $cat_arr[0];?></li>
<?php echo $product->list_attributes(); ?>
<li><?php esc_html_e( 'SKU:', 'woocommerce' ); ?> <span><?php echo $product->get_sku(); ?><span></li>
</ul>
<?php if( $product->get_price_html()) { ?>
<div class="product_price">
<p class="<?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?>"><span><?php echo $product->get_price_html(); ?></span> РУБ / м2</p>
<div class="single_product_text">Cтоимость за квадратный метр материала, без учета стоимости изготовления, доставки и монтажа изделия</div>
</div>
<?php } ?>
<form class="product_price_cart cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<div class="single_product_btn">
Расчитать стоимость
</div>
</form>
</div>
</div>
<?php $the_content = apply_filters( 'the_content', get_the_content() ); ?>
<div class="product_text_container">
<div class="product_text_tabs">
<?php if ( ! empty( $the_content ) ) : ?>
<div class="product_text_tab_title tab_1 active">Описание</div>
<?php endif; ?>
<?php if( have_rows('reviews') ): ?>
<div class="product_text_tab_title tab_2 <?php if ( empty( $the_content ) ) echo 'active'; ?>">Отзывы <span class="count"></span></div>
<?php endif; ?>
</div>
<div class="product_text_tabs_content">
<div class="product_text text_tab_1 active">
<?php the_content(); ?>
</div>
<div class="product_text text_tab_2 <?php if ( empty( $the_content ) ) echo 'active'; ?>">
<div class="product_text_review_container">
<?php
$count=1;
if( have_rows('reviews') ):
while ( have_rows('reviews') ) : the_row(); ?>
<div class="product_review_block">
<div class="product_review_block_left">
<?php if( get_sub_field('doc') ): ?>
<div class="product_review_title"><?php the_sub_field('doc'); ?></div>
<?php endif; ?>
<ul class="product_review_list">
<?php if( get_sub_field('client') ): ?>
<li>Заказчик: <?php the_sub_field('client'); ?></li>
<?php endif; ?>
<?php if( get_sub_field('adress') ): ?>
<li>Адрес: <?php the_sub_field('adress'); ?></li>
<?php endif; ?>
<?php if( get_sub_field('stone') ): ?>
<li>Камень: <?php the_sub_field('stone'); ?></li>
<?php endif; ?>
<?php if( get_sub_field('price') ): ?>
<li>Стоимость: <?php the_sub_field('price'); ?></li>
<?php endif; ?>
</ul>
<div class="product_review_text product_review_text-<? echo $count?>">
<?php if( get_sub_field('text') ): ?>
<div class="product_review_text_title">Текст:</div>
<p><?php the_sub_field('text'); ?></p>
Показать весть текст
<?php endif; ?>
</div>
</div>
<div class="product_review_block_right">
<?php if( have_rows('gallery') ): ?>
<div class="slider-review-for">
<?php while( have_rows('gallery') ): the_row();?>
<div class="slider-review-for-box"><img src="<?php echo get_sub_field('img'); ?>" alt="<?php echo $image['alt']; ?>"></div>
<?php endwhile; ?>
</div>
<div class="slider-review-nav">
<?php while( have_rows('gallery') ): the_row();?>
<div class="slider-review-nav-box"><img src="<?php echo get_sub_field('img'); ?>" alt="<?php echo $image['alt']; ?>"></div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php
$count++;
endwhile;
endif;
?>
<div class="product_text_review_container_btn">Показать все отзывы</div>
</div>
</div>
</div>
</div>
<?php endwhile; // end of the loop. ?>
<?php
$cats_arr = wc_get_product_category_list( $product->get_id()); $cat_arr = explode(",", $cats_arr); $cat = $cat_arr[0]; $mycat = preg_replace('#<a.*?>|</a>#sui', '', $cat);
$id5 = get_the_ID();
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => 4,
'orderby' => 'rand',
'post__not_in' => array($id5),
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'terms' => $mycat,
'field' => 'slug',
),
)
);
$loop = new WP_Query($args);
if ($loop->have_posts())
{ ?>
<div class="relative_products">
<h2>Похожие камни:</h2>
<div class="relative_products_container">
<div class="woocommerce columns-4 ">
<ul class="products oceanwp-row clr grid">
<?php
while ($loop->have_posts()):
$loop->the_post(); ?>
<li class="entry has-media col span_1_of_4 owp-content-left owp-thumbs-layout-horizontal owp-btn-normal owp-tabs-layout-horizontal product type-product post-5856 status-publish first instock product_cat-classical product_cat-95 has-post-thumbnail shipping-taxable purchasable product-type-simple">
<div class="product-inner clr">
<div class="woo-entry-image clr">
<?php if (has_post_thumbnail()): ?>
<img src="<?php the_post_thumbnail_url('large'); ?>" alt="<?php the_title(); ?>">
<?php endif; ?>
</div><!-- .woo-entry-image -->
<ul class="woo-entry-inner clr">
<li class="image-wrap">
<div class="woo-entry-image clr">
<?php if (has_post_thumbnail()): ?>
<img src="<?php the_post_thumbnail_url('large'); ?>" alt="<?php the_title(); ?>">
<?php endif; ?>
</div><!-- .woo-entry-image -->
</li>
<li class="title"><?php the_title(); ?></li>
<li class="category">Категория <?php $cats_arr = wc_get_product_category_list( $product->get_id()); $cat_arr = explode(",", $cats_arr); echo $cat_arr[0];?></li>
</ul>
</div>
</li>
<?php
endwhile; ?>
</ul>
</div>
</div>
</div>
<?php } ?>
<?php
/**
* woocommerce_after_main_content hook.
*
* #hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
<?php
get_footer();
/* Omit closing PHP tag at the end of PHP files to avoid "headers already sent" issues. */
I tried several solutions, tried to make it work via plugin, nothing help.

Add image with Post url after content

I would like to add an image with the link to the post - <?php echo esc_url($theme_post['url']); in the bottom right corner of the class "blog-grid-content".
Could someone please guide me to the best approach?
Thank you
<div class="blog-grid grid-2<?php echo esc_attr( $blog_grid_class ); ?>" <?php echo esc_attr( $anim_attrs ); ?>>
<div class="blog-grid-content">
<?php if ( $theme_post['categories'] ) : ?>
<div class="tags">
<?php if ( in_array( 'sticky', get_post_class( '', $theme_post['post_id'] ) ) ) : ?>
<span class="tag tag-sticky"><?php esc_html_e( 'Featured', 'theme' ); ?></span>
<?php endif; ?>
<?php foreach ($theme_post['categories'] as $_category) : ?>
<a class="tag brand-bg-color" href="<?php echo esc_url( get_category_link( $_category->cat_ID ) ); ?>">
<?php echo esc_html( $_category->name ); ?>
</a>
<?php endforeach; ?>
</div>
</div>
</div>

Wordpress Custom Logo

I'm pretty new about coding, and i'm trying to build a Wordpress custom theme.
I'm stacked on the logo section and I really can't understand what i'm doing wrong:
<?php if ( get_theme_mod('apc_logo_image', '') != '' ): ?>
<img class="animate" src="<?php echo get_template_directory_uri(); ?>/img/logo.png" alt="logo sito">
<?php elseif ( is_front_page() && is_home() ) : ?>
<img class="animate" src="<?php echo get_theme_mod( 'apc_logo_image', '' ); ?>" alt="<?php echo get_theme_mod( 'apc_logo_alt_text', '' ); ?>">
<?php else : ?>
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<?php endif; ?>
I would like to do the follow:
If I upload an images from Customizer, than it would be visible as logo.
If don't and i have a logo in a specific path like: /assets/logo ecc... than it should be visible like logo.
if don't, then I would like to see the name of the website as it should be.
So working code:
<?php
$logoFile = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/themes/' . wp_get_theme()->get('TextDomain') . '/assets/images/logo/logo.png';
if ( (bool)get_theme_mod('apc_logo_image')) : ?>
<img class="animate" src="<?php echo get_theme_mod( 'apc_logo_image'); ?>" alt="<?php echo get_theme_mod( 'apc_logo_alt_text'); ?>">
<?php else : ?>
<?php if ( file_exists($logoFile) ) : ?>
<img class="animate" src="<?php echo '/wp-content/themes/' . wp_get_theme()->get('TextDomain') . '/assets/images/logo/logo.png'?>" alt="logo sito">
<?php else : ?>
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<?php endif; ?>
<?php endif ?>

Wrap every 3 divs in a divs

This show 3 image at a time and move left 3 images at a time this is my problem. I want that show 3 images at a time and move left only one at a time. For Example, 4 image add it and three show at a time and when move one image then also show three image at a time. And then move one and than also show three images like http://wmh.github.io/jquery-scrollbox/ Example No 5 and 6...*
Note: $Cat_ID is categories..
<div class="cat-box-content">
<?php if($cat_query->have_posts()): ?>
<div id="slideshow<?php echo $Cat_ID ?>" class="group_items-box">
<?php while ( $cat_query->have_posts() ) : $cat_query->the_post()?>
<div <?php tie_post_class('scroll-item'); ?>>
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'tie' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php //the_post_thumbnail( 'thumbnail' ); ?>
<?php tie_thumb( 'tie-large' ); ?>
<span class="overlay-icon"></span>
</a>
</div><!-- post-thumbnail /-->
<?php endif; ?>
<h3 class="post-box-title"><?php the_title(); ?></h3>
<p class="post-meta">
<?php if( tie_get_option( 'box_meta_score' ) ) tie_get_score(); ?>
<?php if( tie_get_option( 'box_meta_date' ) ) tie_get_time() ?>
</p>
</div>
<?php endwhile;?>
<div class="clear"></div>
</div>
<div id="nav<?php echo $Cat_ID ?>" class="scroll-nav"></div>
<?php endif; ?>
</div>
JQuery Function :
<script type="text/javascript">
jQuery(document).ready(function() {
var vids = jQuery("#slideshow<?php echo $Cat_ID ?> .scroll-item");
for(var i = 0; i < vids.length; i+=3) {
vids.slice(i, i+3).wrapAll('<div class="group_items"></div>');
}
jQuery(function() {
jQuery('#slideshow<?php echo $Cat_ID ?>').cycle({
fx: 'scrollHorz',
timeout: 3000,
pager: '#nav<?php echo $Cat_ID ?>',
slideExpr: '.group_items',
speed: 1000,
pause: true
});
});
});
</script>

Setting the_post_thumbnail width to 100%

How to set the_post_thumbnail so that it doesn't use an array for its size, but instead can be set with a 100% width and auto height:
<?php $ht_featured_img = get_option('ht_featured_img');
if ($ht_featured_img == "true") { ?>
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { /* if post has a thumbnail */ ?>
<div class="post-image">
<?php the_post_thumbnail( array(1215,9999) ); ?>
</div><!--post-image-->
<?php } ?>
<?php } ?>
<?php $ht_featured_img = get_option('ht_featured_img'); if ($ht_featured_img == "true") { ?>
<?php if ( ( function_exists('has_post_thumbnail') ) && ( has_post_thumbnail() ) ) {
$post_thumbnail_id = get_post_thumbnail_id();
$post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );
?>
<div class="post-image">
<img title="image title" alt="thumb image" class="wp-post-image" src="<?php echo $post_thumbnail_url; ?>" style="width:100%; height:auto;">
</div>
<?php } ?>
<?php } ?>
<? if( has_post_thumbnail( $post_id ) ): ?>
<div class="post-image">
<img title="image title" alt="thumb image" class="wp-post-image"
src="<?=wp_get_attachment_url( get_post_thumbnail_id() ); ?>" style="width:100%; height:auto;">
</div>
<? endif; ?>
You could also just use
<img src="<?php echo get_the_post_thumbnail_url (); ?>" style="width:100%; height:auto;">

Resources