Skip to main content
We are Brand SEO Beijing serving international business, your marketing partner, Contact us by mi@mgsh.com.cn

How to add a footer link in the widget?

Make the website friendly link beautiful and generous, it is every website administratorWebsite optimizationthings you care about.It can not only control the location where the friendship link appears, such as footer, but also control the footer to only appear on the home page is_home(), and at the same time, it can also satisfy the custom widget Widget area, and can call the widget id, then, this does require a series of conditions .

Create a gadget

First, create custom widgets through widgetsAreas.php.

widget_areas ) ) { foreach ( array_unique( $this->widget_areas ) as $widget_area ) { $widget_area = wp_strip_all_tags( $widget_area ); $args = array( 'id' => sanitize_key( $widget_area ), 'name' => $ widget_area, 'class' => 'wpex-custom', 'before_widget' => ' ', 'after_widget' => ' ', 'before_title' => '<' . $tag_escaped . ' class="widget-title">', 'after_title' => ' ', ); register_sidebar( $args ); } } }

Of course, I need to change the format, then I will cancel the class first,

foreach ( $sidebars as $k => $v )

{ $args = array( 'id' => sanitize_key( $k ), 'before_widget' => ' ', the class in the delete. (Not finding widgets-ini in wp-actions, but WidgetAreas.php in /www.mgsh.com.cn/wp-content/plugins/mgsh-theme-core/inc/…

Restart the php server, half done.

Adjust style

Next, put it in footer.php and decide to adjust the style and class here



Then, in the custom gadget, you can sneak into the link in the form of text or HTML.

Tested text and other templates have formatting problems, do not use text as a link, the text widget is automatically generatedlabel, which causes the bottom to automatically increase by 20px, resulting in redundant positions; pure code still uses HTML, which is a perfect solution.

Remaining problem:

line-height: element.style of 50px, making the link wrapping ugly, I want to replace 50px with 30px;


 

Control the friend chain on the home page

Finally, if you still want to operate the widget, only display it on the home page and not on other pages, then you need to perform logic logic processing on the widget.

Supplement: class uses spaces to call multiple classes, extended knowledge of . and #:

. The dot represents a class class, which can be called by multiple tags
, indicating that styles with a unified du attribute are written together to save code
# Indicates daoID, id is unique, a page can only be referenced once, and .class can be reused multiple times.
example:
i am red
I am also connected in red
.color{color:red;}
,example
.a{color:#red;font-size:14px;}
.b{color:#red;font-size:16px;}
.c{color:#red;font-size:18px;}
You can see that they all have a common feature that is color: red; this is what we can simply abbreviate into:
.a,.b,.c{color:#red}
.a{font-size:14px;}
.b{font-size:16px;}
.c{font-size:18px;}
And there is only one id per page, and its css priority is also the highest. If a tag contains a class and an id at the same time, and both the id and the class have a definition of the same type, the style of the id will eventually take precedence.
Such as:
.a{color:red;}
#b{color:#000;}
i am id first: black connection

Extended reading:

What are the nofollow and _blank setting principles for SEO hyperlinks?

Affiliate Links of SEO Those Things Are Perfectly Matched

How is the brand screen optimization case done?

What competencies should a valuable SEOer possess?

Back to Top