Reputation: 657
I want to change the URL path when clicked on the logo. I tried changing the direction but it didn't work.
<?php
//set logo path
$logo_path = sq_option_url( 'logo' );
$logo_path = apply_filters( 'kleo_logo', $logo_path );
$social_icons = apply_filters( 'kleo_show_social_icons', sq_option( 'show_social_icons', 1 ) );
$top_bar = sq_option( 'show_top_bar', 1 );
$top_bar = apply_filters( 'kleo_show_top_bar', $top_bar );
$top_menu = wp_nav_menu( array(
'theme_location' => 'top',
'depth' => 2,
'container' => 'div',
'container_class' => 'top-menu col-sm-12 col-md-7 no-padd',
'menu_class' => '',
'fallback_cb' => '',
'walker' => new kleo_walker_nav_menu(),
'echo' => false
)
);
$primary_menu = wp_nav_menu( array(
'theme_location' => 'primary',
'depth' => 3,
'container' => 'div',
'container_class' => 'collapse navbar-collapse nav-collapse',
'menu_class' => 'nav navbar-nav',
//'fallback_cb' => 'kleo_walker_nav_menu::fallback',
'fallback_cb' => '',
'walker' => new kleo_walker_nav_menu(),
'echo' => false
)
);
?>
<div id="header" class="header-color">
<div class="navbar" role="navigation">
<?php if ($top_bar == 1) { //top bar enabled ?>
<!--Attributes-->
<!--class = social-header inverse-->
<div class="social-header header-color">
<div class="container">
<div class="top-bar">
<div id="top-social" class="col-sm-12 col-md-5 no-padd">
<?php echo kleo_get_social_profiles(); ?>
</div>
<?php
// Top menu
echo $top_menu;
?>
</div><!--end top-bar-->
</div>
</div>
<?php } //end top bar condition ?>
<?php
$header_style = sq_option( 'header_layout', 'normal' );
if ( $header_style == 'right_logo' ) {
$header_class = ' logo-to-right';
} elseif ( $header_style == 'center_logo' ) {
$header_class = ' header-centered';
} elseif ( $header_style == 'left_logo' ) {
$header_class = ' header-left';
} else {
$header_class = ' header-normal';
}
?>
<div class="kleo-main-header<?php echo $header_class;?>">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<div class="kleo-mobile-switch">
<?php
$mobile_menu_atts = 'class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse"';
/* open the Side menu instead of the normal menu */
if ( sq_option( 'side_menu_mobile', 0 ) == 1 ) {
$mobile_menu_atts = 'class="navbar-toggle open-sidebar"';
}
?>
<button type="button" <?php echo $mobile_menu_atts;?>>
<span class="sr-only"><?php _e("Toggle navigation",'kleo_framework');?></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="kleo-mobile-icons">
<?php
/** kleo_mobile_header_icons - action
* You can put here various icons using this action
*
* @hooked kleo_bp_mobile_notify - 9
* @hooked kleo_woo_mobile_icon - 10
*/
do_action( 'kleo_mobile_header_icons' );
?>
</div>
<strong class="logo">
<a href="http://hpkursen.se/hem/">
<?php if ($logo_path != '') { ?>
<img id="logo_img" title="<?php bloginfo('name'); ?>" src="<?php echo $logo_path; ?>" alt="<?php bloginfo('name'); ?>">
<?php } else { ?>
<?php bloginfo('name'); ?>
<?php } ?>
</a>
</strong>
</div>
<?php if ($header_style == 'left_logo') : ?>
<div class="header-banner">
<?php echo do_shortcode( sq_option( 'header_banner', '' ) );?>
</div>
<?php endif; ?>
<!-- Collect the nav links, forms, and other content for toggling -->
<?php
// Main menu
echo $primary_menu;
?>
</div><!--end container-->
</div>
</div>
</div>
The URL I want to redirect to instead of home is hpkursen.se/hem/
I tried to change the <a href="<?php echo home_url();?>">
to <a href="http://hpkursen.se/hem/">
but it still redirects to the Homepage when clicked. Does anyone know what the problem is?
Upvotes: 0
Views: 1943
Reputation: 3434
You have the answer to your question:
Use <a href="<?php echo home_url();?>/hem/"
> and it should work.
For more details/examples, please visit: https://codex.wordpress.org/Function_Reference/home_url
EDIT
I connected to your website and it seems that you're not editing the right file :) . You have this piece of code: $header_style = sq_option( 'header_layout', 'normal' );
Search for the file "header_layout". Search for this in your files:
<header>
<a class="logo" style="width:395px" href="http://hpkursen.se" rel="home">
<img alt="logo" src="http://hpkursen.se/wp-content/uploads/2015/01/logo_org_b.png">
</a>
</header>
Make sure you opened the right header file!
EDIT 2
There are two options:
1. Edit plugin
Go to: wp-content/plugins/maintenance/load/functions.php
On the line 155 you will find this:
function get_logo_box() {
$mt_options = mt_get_plugin_options(true);
$out_html = '';
if ( !empty($mt_options['logo']) ) {
$logo = wp_get_attachment_image_src( $mt_options['logo'], 'full');
$out_html = '<a class="logo" rel="home" href="'.esc_url(site_url('')) .'" style="width:'.$logo[1].'px">';
$out_html .= '<img src="'. esc_url($logo[0]) .'" alt="logo"/>';
$out_html .= '</a>';
} else {
$out_html = '<a class="logo istext" rel="home" href="'.esc_url(site_url('')) .'">';
$out_html .= '<h1 class="site-title">'. get_bloginfo( 'name' ) .'</h1>';
}
$out_html .= '</a>';
echo $out_html;
}
add_action ('logo_box', 'get_logo_box', 10);
Replace it with:
function get_logo_box() {
$mt_options = mt_get_plugin_options(true);
$out_html = '';
if ( !empty($mt_options['logo']) ) {
$logo = wp_get_attachment_image_src( $mt_options['logo'], 'full');
$out_html = '<a class="logo" rel="home" href="'.esc_url(site_url('/hem/')) .'" style="width:'.$logo[1].'px">';
$out_html .= '<img src="'. esc_url($logo[0]) .'" alt="logo"/>';
$out_html .= '</a>';
} else {
$out_html = '<a class="logo istext" rel="home" href="'.esc_url(site_url('/hem/')) .'">';
$out_html .= '<h1 class="site-title">'. get_bloginfo( 'name' ) .'</h1>';
}
$out_html .= '</a>';
echo $out_html;
}
add_action ('logo_box', 'get_logo_box', 10);
What I did was replacing this line: $out_html = '<a class="logo" rel="home" href="'.esc_url(site_url('/')) .'" style="width:'.$logo[1].'px">';
with this line: $out_html = '<a class="logo" rel="home" href="'.esc_url(site_url('/hem/')) .'" style="width:'.$logo[1].'px">';
2. Edit your theme's functions.php file
Go to wp-content/themes/your theme and open the file: functions.php
At the end of this file add:
function get_logo_box() {
$mt_options = mt_get_plugin_options(true);
$out_html = '';
if ( !empty($mt_options['logo']) ) {
$logo = wp_get_attachment_image_src( $mt_options['logo'], 'full');
$out_html = '<a class="logo" rel="home" href="'.esc_url(site_url('/hem/')) .'" style="width:'.$logo[1].'px">';
$out_html .= '<img src="'. esc_url($logo[0]) .'" alt="logo"/>';
$out_html .= '</a>';
} else {
$out_html = '<a class="logo istext" rel="home" href="'.esc_url(site_url('/hem/')) .'">';
$out_html .= '<h1 class="site-title">'. get_bloginfo( 'name' ) .'</h1>';
}
$out_html .= '</a>';
echo $out_html;
}
add_action ('logo_box', 'get_logo_box', 10);
In this way you will override the plugin's function.
Upvotes: 1