-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.php
More file actions
113 lines (94 loc) · 3.4 KB
/
functions.php
File metadata and controls
113 lines (94 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/*
Final Decisions Theme
Functions and definitions
*/
/*
Add title support.
Wordpress requires all themes support title-tag. See https://make.wordpress.org/themes/2015/08/25/title-tag-support-now-required.
*/
function theme_slug_setup()
{
add_theme_support("title-tag");
}
add_action("after_setup_theme", "theme_slug_setup");
/*
Enqueue all styles and scrips
*/
function my_queue()
{
// Google Fonts
// wp_enqueue_style("google_fonts", "https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,700;1,400;1,700&family=Raleway:ital,wght@0,400;0,700;1,400&display=swap");
// De-register the built-in jQuery and register a more recent version.
wp_deregister_script('jquery');
wp_enqueue_script('jquery', 'https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js', true);
// Register Bootstrap
wp_enqueue_style("main", get_template_directory_uri() . "/css/main.css");
wp_enqueue_style("bootstrap-icons", "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css", true);
wp_enqueue_script("bootstrap-js", "https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js", true);
// Register Headroom.js
wp_enqueue_script("headroomjs", get_template_directory_uri() . "/js/headroom.min.js", true);
// And finally register my JavaScript
wp_enqueue_script('main', get_template_directory_uri() . '/js/main.js', true);
}
add_action("wp_enqueue_scripts", "my_queue");
/*
Add classes to next-post & previous-post links.
See https://css-tricks.com/snippets/wordpress/add-class-to-links-generated-by-next_posts_link-and-previous_posts_link.
*/
add_filter("next_posts_link_attributes", "posts_link_attributes");
add_filter("previous_posts_link_attributes", "posts_link_attributes");
function posts_link_attributes()
{
return 'class="my-5 col-5 col-md-3 btn btn-lg btn-outline-light"';
}
/*
Change the "Read more" text and style.
See https://codex.wordpress.org/Customizing_the_Read_More.
*/
function modify_read_more_link()
{
//return "<div class='row'><a class='btn btn-outline-light mx-auto' style='width:180px' href='" . get_permalink() . "'>Continue Reading</a></div>"
return '<a href="<?php echo get_permalink() ?>">Continue reading....</a>';
}
add_filter("the_content_more_link", "modify_read_more_link");
/*
Dynamic copyright date.
See https://www.wpbeginner.com/wp-tutorials/how-to-add-a-dynamic-copyright-date-in-wordpress-footer/.
*/
function dynamic_copyright()
{
global $wpdb;
$copyright_dates = $wpdb->get_results("
SELECT
YEAR(min(post_date_gmt)) AS firstdate,
YEAR(max(post_date_gmt)) AS lastdate
FROM
$wpdb->posts
WHERE
post_status = 'publish'
");
$output = "";
if ($copyright_dates) {
$copyright = "Copyright " . $copyright_dates[0]->firstdate;
if ($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
$copyright .= '-' . $copyright_dates[0]->lastdate;
}
$output = $copyright;
}
return $output;
}
/*
Exclude Pages from search.
See https://www.wpbeginner.com/wp-tutorials/how-to-exclude-pages-from-wordpress-search-results/.
*/
if (!is_admin()) {
function wpb_search_filter($query)
{
if ($query->is_search) {
$query->set("post_type", "post");
}
return $query;
}
add_filter("pre_get_posts", "wpb_search_filter");
}