使用过滤器将博客标题更改为图像

时间:2018-02-16 07:32:29

标签: php wordpress wordpress-theming

嘿伙计们,我正在尝试将博客标题更改为图片。

这就是我想要实现的目标

我尝试将此代码添加到css中,但它正在运行。

EventLogReader reader = new 
EventLogReader(eventLogQuery);
                reader.Seek(SeekOrigin.Begin, filter.PageStart);

eventLogs.TotalLogs = **totalRowsAffected**;                    
EventRecord eventInstance = reader.ReadEvent();

int i = filter.PageSize;
while (eventInstance != null && i-- > 0)
{
 try
 {
  eventLogs.Entries.Add(new EventLogData
  {
   Type = eventInstance.LevelDisplayName,
   Source = eventInstance.ProviderName,
   Time = eventInstance.TimeCreated,
   Category = eventInstance.TaskDisplayName,
   EventId = eventInstance.Id,
   User = eventInstance.UserId != null ? eventInstance.UserId.Value : "",
   Computer = eventInstance.MachineName,
   Message = eventInstance.FormatDescription(),
   FullXml = eventInstance.ToXml()
  });
 }catch{}
eventInstance = reader.ReadEvent();
}
}
return eventLogs;

这是结果

图像显示不够。但我想将它添加到我的子主题中的functions.php中。我试过这段代码

.rh-content {
text-indent: -9999px;
background: url(http:file-location.png) 10px 10px no-repeat;
/* height: 100%; */
}

但这是结果。这是我在添加过滤功能时所看到的

这是原始代码

add_filter('the_title', function($title){ 
$title = '<img src="'. get_template_directory_uri() .'/images/blah.png">' . 
$title;
return $title;
}); ?>

这是网址链接。 https://harborllc.wpengine.com/blogs/

非常感谢你们

1 个答案:

答案 0 :(得分:0)

我刚刚将代码替换为javascript

jQuery(function($) {
$('.rh-content h1').replaceWith(function(){
    return $('<img src="https://harborllc.wpengine.com/wp-content/uploads/2018/01/Harbor-Enterprises-Logo-Transparent-White-Outline-Revised-2.png"/>', {
        html: this.innerHTML
    })
})
});