有没有办法从CSS链接中更改href值?

时间:2015-10-02 14:08:50

标签: html css wordpress

我有一个wordpress主题,不授予.html文件的访问权限,它加载了我需要样式的html:

<!--Header Start-->

<?php get_template_part( 'templates/headers/xv', 'nav' ); ?>

<?php get_template_part( 'templates/headers/search', 'bar' ); ?>

我需要在标题中进行更改,有一个简单的链接需要更改

<a class="navbar-brand" href="http://THISMUSTBECHNAGED.eu/">
<img src="Image.png" >
</a>

我已经检查了模板本身提供的所有可能性,并没有发现更改链接目的地的可能性,Wordpress中的文本编辑器也允许访问所有.php文件,但它们都没有使用导航栏,它从我在第一个代码示例中显示的get_template_part加载它。

多数民众赞成我尝试使用巫婆JS,但没有奏效:

jQuery(document).ready(function(){
    document.getElementByClassName("navbar-brand").href="NEWLINK";
});

jQuery(document).ready(function(){
    $(".navbar-brand").attr("href", "NEWLINK")
});

jQuery(document).ready(function(){
    var x = document.getElementsByClassName("navbar-brand");
    x[0].href = "NEWLINK";
});

有没有办法用css选择这个href并以这种方式更改链接?

主题是:http://xvelopers.com/wp/themes/voltov/

Full header.php:

<?php?>

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--   >
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html <?php language_attributes(); ?> class="no-js">
<!--<![endif]-->
<?php global $xv_data; //fetch options stored in $xv_data ?>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1, user-scalable=no" />
<link rel="shortcut icon" href="<?php if(!empty($xv_data['fav_icon']

['url'])){ echo esc_url($xv_data['fav_icon']['url']);}else{ echo 

esc_url(get_template_directory_uri() .  '/assets/img/favicon.png'); }?>" type="image/x-icon" />
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

<?php wp_head(); ?>
</head>

<body <?php body_class(); ?> data-spy="scroll" data-target=".pages-wrapper">
<div class="wrapAllContent">
<!--Header Start-->

<?php get_template_part( 'templates/headers/xv', 'nav' ); ?>

<?php get_template_part( 'templates/headers/search', 'bar' ); ?>

修改

这是用于创建navbar元素的.php,而homelink是通过boolean = true创建的,将其设置为false并不会使我的JS工作。我不知道如何定制这个:

    <?php

/**

 * xvelopers's Theme Core Functions 

 *

 * Eventually, some of the functionality here could be replaced by core features

 *

 * @package voltov

 */



/**

 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.

 *

 * @param array $args Configuration arguments.

 * @return array

 */

function voltov_page_menu_args( $args ) {

    $args['show_home'] = true;

    return $args;

}

add_filter( 'wp_page_menu_args', 'voltov_page_menu_args' );







/**

 * Adds custom classes to the array of body classes.

 *

 * @param array $classes Classes for the body element.

 * @return array

 */

    function voltov_body_classes( $classes ) {

        // Adds a class of group-blog to blogs with more than 1 published author.





             // Adds a class of group-blog to blogs with more than 1 published author.

        if ( is_multi_author() )

            $classes[] = 'group-blog';



        if(is_archive() || is_search())

            $classes[] =  'sidebar-disabled';



          return $classes;

      }

      add_filter( 'body_class', 'voltov_body_classes' );





    //add active class in selected page

    add_filter('nav_menu_css_class' , 'voltov_nav_class' , 10 , 2);

    function voltov_nav_class($classes, $item){

         if( in_array('current-menu-item', $classes) ){

                 $classes[] = 'active ';  // your new class

         }

         return $classes;

    }





    /*

     Custom Excerpt

    */

    function voltov_get_excerpt($count,$read=true){

     global $post;

      $permalink = get_permalink($post->ID);

      $excerpt = get_the_content();

      $excerpt = strip_tags($excerpt);

      $excerpt = substr($excerpt, 0, $count);

      $excerpt = substr($excerpt, 0, strripos($excerpt, " "));



      if($read != false){

             $excerpt = $excerpt.'<a class="readmore" href="'.$permalink.'"> '. __('Weiterlesen','voltov').'</a>';

      }

      echo wp_kses($excerpt,'a');

    }





    /*

    * Pagination code

    */

    function voltov_get_pagination($pages = '', $range = 4)



    { 

         $showitems = ($range * 2)+1; 

         global $paged;

         if(empty($paged)) $paged = 1;

         if($pages == '')

         {

             global $wp_query;

             $pages = $wp_query->max_num_pages;

             if(!$pages)

             {

                 $pages = 1;

             }

         }  

         if(1 != $pages)

         {

             echo "<div class=\"pagination\">";

             if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo; First</a>";

              previous_posts_link('<i class="icon-chevron-left pagination-icon"></i>');

              //echo "<a href='".get_pagenum_link($paged - 1)."'><i class='icon-chevron-left pagination-icon'></i></a>";

             for ($i=1; $i <= $pages; $i++)

             {

                 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))



                 {

                     echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";

                 }

             }

              //echo "<a href=\"".get_pagenum_link($paged + 1)."\"><i class='icon-chevron-right pagination-icon'></i></a>"; 

              next_posts_link('<i class="icon-chevron-right pagination-icon"></i>','');

             if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last &raquo;</a>";

             echo "</div>\n";

         }

    }





    /**

     * Thumbnail Resizer & Image functions

     *

     */



         function xv_get_resizer($image_url='',$width='',$height='',$crop='c'){



                $image ="http://placehold.it/{$width}x{$height}";





                if (!empty($image_url)) {        



                    $image = theme_thumb($image_url, $width, $height,$crop);

                }



                return esc_url($image);

        }



        function xv_get_thumbnail($width,$height){

            global $post;    



              $thumb ="http://placehold.it/{$width}x{$height}";

                 if ( has_post_thumbnail() ) {        

                    $image_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "full");

                    $image_url = $image_src[0];

                    $thumb = theme_thumb($image_url, $width, $height, 'c');

                }



            return esc_url($thumb);

         }

        function xv_get_thumbnail_url($size = 'full'){

        global $post;    





             if ( has_post_thumbnail() ) {        

                $image_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $size);

                $image_url = $image_src[0];

            }else{

                $image_url = 'No Image';

            }



            return esc_url($image_url);

         }



        function xv_get_image_url($post_id){



                $image_src = wp_get_attachment_image_src( $post_id, "full");

                $image_url = $image_src[0];

                return esc_url($image_url);

         }



    /**

     * Checks if a post thumbnails is already defined.

     *

     */

    function voltov_is_post_thumbnail_set()

    {

        global $post;

        if (get_the_post_thumbnail()) {

            return true;

        } else {

            return false;

        }

    }





    function voltov_autoset_featured_img()

    {

        global $post;



        $post_thumbnail = voltov_is_post_thumbnail_set();

        if ($post_thumbnail == true) {

            return get_the_post_thumbnail();

        }

        $image_args     = array(

            'post_type'      => 'attachment',

            'numberposts'    => 1,

            'post_mime_type' => 'image',

            'post_parent'    => $post->ID,

            'order'          => 'desc'

        );

        $attached_images = get_children($image_args, ARRAY_A);

        $first_image = reset($attached_images);

        if (!$first_image) {

            return false;

        }



        return get_the_post_thumbnail($post->ID, $first_image['ID']);

    }  



      function xv_get_sidebars_array() {

        global $xv_data;



        $sidebars = array();

        $sidebars['default'] = __('Default', 'framework');

        if (isset($xv_data) && isset($xv_data['custom-sidebars']) && is_array($xv_data['custom-sidebars'])) {

          foreach ($xv_data['custom-sidebars'] as $sidebar) {

            $sidebars[sanitize_title ( $sidebar )] = $sidebar;

          }

        }

        return $sidebars;

      }

      function xv_page_sidebar_id($position, $default = 'default')

      {

        if (function_exists('get_field')) {

          $sidebar = get_field($position);

        } else {

          $sidebar = '';

        }

        if (empty($sidebar))

        {

          $sidebar = $default;

        }

        return $sidebar;

      }



      function xv_get_post_type_categories($post_type='')

      {

          if(!empty($post_type)){



              $terms = get_terms($post_type);



          }else{



              $args = array(

                'orderby' => 'name',

                'parent' => 0

                );

              $terms = get_categories( $args );



              }





              $categories = array();

              $categories[__('All', 'framework')] = '';

              foreach ( $terms as $term ) {

                  $categories[] = $term->slug;

              }









              return $categories;



      }



      function xv_get_posts_list($post_type='')

      {

          global $post;





          $args       = array( 'numberposts' => -1,'post_type'=>$post_type);

          $posts      = get_posts($args);

          $posts_list = array();



          foreach( $posts as $post ) : setup_postdata($post); 





                  $posts_list[] =  get_the_title( $post_id ) ;



                      // );





          endforeach;





              return $posts_list;



      }



    /**

     *  Include Menu Walker Class

     *

     */



      function xv_set_post_views($postID) {

          $count_key = 'wpb_post_views_count';

          $count = get_post_meta($postID, $count_key, true);

          if($count==''){

              $count = 0;

              delete_post_meta($postID, $count_key);

              add_post_meta($postID, $count_key, '0');

          }else{

              $count++;

              update_post_meta($postID, $count_key, $count);

          }

      }

      //To keep the count accurate, lets get rid of prefetching

      remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);





add_filter('mce_buttons','wysiwyg_editor');

function wysiwyg_editor($mce_buttons) {

    $pos = array_search('wp_more',$mce_buttons,true);

    if ($pos !== false) {

        $tmp_buttons = array_slice($mce_buttons, 0, $pos+1);

        $tmp_buttons[] = 'wp_page';

        $mce_buttons = array_merge($tmp_buttons, array_slice($mce_buttons, $pos+1));

    }

    return $mce_buttons;

}

谢谢!

编辑2:

好的,我只是尝试上传标题的其他徽标,它会自动创建一个到网站本身的主链接并禁用访问权限以更改链接。所以我想这个主题根本不可能。

0 个答案:

没有答案