change font navigation text
-
Hello,
I’m trying to change the text on post navigation ‘buttons’ from ‘previous post’ to ‘previous’ and ‘next post’ to ‘next’. see bottom of page, here: https://test.zedonk.net/better/
I’ve been looking in the code as best i can but can’t find what is controlling it.
Any pointers?
-
Hi Zedonk!
In order to do this you need to modify the template-tags.php file inside the theme folder>inc, be sure to change the file in your child theme, not you parent theme.
The code you need to change is this part:
<?php previous_post_link( '<div class="nav-previous">%link</div>', _x( '<span class="meta-nav">←</span>?Previous Post', 'Previous post link', 'intergalactic' ) ); next_post_link( '<div class="nav-next">%link</div>', _x( 'Next Post?<span class="meta-nav">→</span>', 'Next post link', 'intergalactic' ) ); ?>
Change it to this:
<?php previous_post_link( '<div class="nav-previous">%link</div>', _x( '<span class="meta-nav">←</span>?Previous', 'Previous post link', 'intergalactic' ) ); next_post_link( '<div class="nav-next">%link</div>', _x( 'Next?<span class="meta-nav">→</span>', 'Next post link', 'intergalactic' ) ); ?>
It is a fuction which displays the Next and previous post buttons. That’s why you need to go into this file.
Hope this was helpful.
Cheers
?yvind
[Signature moderated]hey TouchCoding please answer me too
_ 1- i want put site title of twenty twelve theme inside the navbar
_ 2- i want make navigationbar sticky
_ 3- i want input searchbar inside nav bar ..please help
Thanks touchcoding!
I’m pretty new to all this and can’t find the exact code you mention in the intergalactic template-tags.php, which I’ve copied in full below. Which section do i need to change exactly? Also, to change via child theme do i replicate the theme file structure and pop file in there? ie /intergalactic-child/inc/template-tags.php?
Super appreciative of your help!
<?php
/**
* Custom template tags for this theme.
*
* Eventually, some of the functionality here could be replaced by core features.
*
* @package Intergalactic
*/if ( ! function_exists( ‘intergalactic_paging_nav’ ) ) :
/**
* Display navigation to next/previous set of posts when applicable.
*/
function intergalactic_paging_nav() {
// Don’t print empty markup if there’s only one page.
if ( $GLOBALS[‘wp_query’]->max_num_pages < 2 ) {
return;
}
?>
<nav class=”navigation paging-navigation” role=”navigation”>
<h1 class=”screen-reader-text”><?php _e( ‘Posts navigation’, ‘intergalactic’ ); ?></h1>
<div class=”nav-links”><?php if ( get_next_posts_link() ) : ?>
<div class=”nav-previous”><?php next_posts_link( __( ‘<span class=”meta-nav”>←</span> Older posts’, ‘intergalactic’ ) ); ?></div>
<?php endif; ?><?php if ( get_previous_posts_link() ) : ?>
<div class=”nav-next”><?php previous_posts_link( __( ‘Newer posts <span class=”meta-nav”>→</span>’, ‘intergalactic’ ) ); ?></div>
<?php endif; ?></div><!– .nav-links –>
</nav><!– .navigation –>
<?php
}
endif;if ( ! function_exists( ‘intergalactic_post_nav’ ) ) :
/**
* Display navigation to next/previous post when applicable.
*/
function intergalactic_post_nav() {
// Don’t print empty markup if there’s nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, ”, true );
$next = get_adjacent_post( false, ”, false );if ( ! $next && ! $previous ) {
return;
}
?>
<nav class=”navigation post-navigation” role=”navigation”>
<h1 class=”screen-reader-text”><?php _e( ‘Post navigation’, ‘intergalactic’ ); ?></h1>
<div class=”nav-links”>
<?php
previous_post_link( ‘<div class=”nav-previous”>%link</div>’, _x( ‘<span class=”meta-nav”>←</span> Previous Post’, ‘Previous post link’, ‘intergalactic’ ) );
next_post_link( ‘<div class=”nav-next”>%link</div>’, _x( ‘Next Post <span class=”meta-nav”>→</span>’, ‘Next post link’, ‘intergalactic’ ) );
?>
</div><!– .nav-links –>
</nav><!– .navigation –>
<?php
}
endif;if ( ! function_exists( ‘intergalactic_posted_on’ ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function intergalactic_posted_on() {
$time_string = ‘<time class=”entry-date published updated” datetime=”%1$s”>%2$s</time>’;
if ( get_the_time( ‘U’ ) !== get_the_modified_time( ‘U’ ) ) {
$time_string = ‘<time class=”entry-date published” datetime=”%1$s”>%2$s</time><time class=”updated” datetime=”%3$s”>%4$s</time>’;
}$time_string = sprintf( $time_string,
esc_attr( get_the_date( ‘c’ ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( ‘c’ ) ),
esc_html( get_the_modified_date() )
);$posted_on = sprintf(
_x( ‘Posted on %s’, ‘post date’, ‘intergalactic’ ),
‘‘ . $time_string . ‘‘
);$byline = sprintf(
_x( ‘by %s’, ‘post author’, ‘intergalactic’ ),
‘<span class=”author vcard”>‘ . esc_html( get_the_author() ) . ‘</span>’
);echo ‘<span class=”posted-on”>’ . $posted_on . ‘</span><span class=”byline”> ‘ . $byline . ‘</span>’;
}
endif;/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function intergalactic_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( ‘intergalactic_categories’ ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array(
‘fields’ => ‘ids’,
‘hide_empty’ => 1,// We only need to know if there is more than one category.
‘number’ => 2,
) );// Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats );set_transient( ‘intergalactic_categories’, $all_the_cool_cats );
}if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so intergalactic_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so intergalactic_categorized_blog should return false.
return false;
}
}/**
* Flush out the transients used in intergalactic_categorized_blog.
*/
function intergalactic_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( ‘intergalactic_categories’ );
}
add_action( ‘edit_category’, ‘intergalactic_category_transient_flusher’ );
add_action( ‘save_post’, ‘intergalactic_category_transient_flusher’ );/**
* Returns the URL from the post.
*
* @uses get_the_link() to get the URL in the post meta (if it exists) or
* the first link found in the post content.
*
* Falls back to the post permalink if no URL is found in the post.
*
* @return string URL
*/
function intergalactic_get_link_url() {
$content = get_the_content();
$has_url = get_url_in_content( $content );return ( $has_url ) ? $has_url : apply_filters( ‘the_permalink’, get_permalink() );
}/*
* Return the post format, linked to the post format archive
*/
function intergalactic_post_format() {
$format = get_post_format();
$formats = get_theme_support( ‘post-formats’ );//If the post has no format, or if it’s not a format supported by the theme, return
if ( ! $format || ! has_post_format( $formats[0] ) )
return;printf( ‘%3$s‘,
esc_url( get_post_format_link( $format ) ),
esc_attr( sprintf( __( ‘All %1$s posts’, ‘intergalactic’ ), get_post_format_string( $format ) ) ),
get_post_format_string( $format )
);
}Immediately that i post that i now of course see the code! Dunno why my find didn’t pick it up. edit and give it a go.
point remains about file structure tho
so, code changed to:
previous_post_link( ‘<div class=”nav-previous”>%link</div>’, _x( ‘<span class=”meta-nav”>←</span> Previous’, ‘Previous post link’, ‘intergalactic’ ) );
next_post_link( ‘<div class=”nav-next”>%link</div>’, _x( ‘Next <span class=”meta-nav”>→</span>’, ‘Next post link’, ‘intergalactic’ ) );
and file is /intergalactic-child/inc/template-tags.php
but not fixed it:
Hi there Karwan Mino!
Try adding this css to your child theme or custom css plugin:
hgroup { display: inline-block; float: left; margin-left: 2%; } @media screen and (min-width: 600px) { .main-navigation ul.nav-menu, .main-navigation div.nav-menu > ul { border: none; } .nav-menu li { float: right; margin-top: 20% } #site-navigation{ float: right; display: inline-block; } } .home { margin-top: 15%; } .site-header { position: fixed; background: whitesmoke; top: 0; right: 0; left: 0; z-index: 99; } .menu-toggle { margin-top: 5%; }
Did that solve your problem?
Cheers
?yvind
[Signature moderated]Hi zedonk!
Yes, you just need to copy template-tags.php into your child theme. In your css file in the child theme link it to the parent and it should work. What does the buttons say now? What went wrong?Cheers
?yvind
[Signature moderated]Hi touchcoding,
thanks so much for coming back to me.
so i copied the code you provided, and then the entire contents of template-tags.php to my child theme css and neither had any effect, the text on buttons is exactly as it was originally, see: https://test.zedonk.net/better/
sorry its taking a while to get this sorted. what is it that i”m doing wrong?
Hi Zedonk!
I didn’t mean to copy it into the css. What you need to do is to replace the code in template-tags.php inside the child theme, not in the parent. be sure to have the child theme as the active theme and link to the parent in the style.css
Cheers
?yvind
[Signature moderated]So i have copied your code over the offending code and saved the template-tags.php in /themes/intergalactic-child/inc i have then set intergalactic child to be active but still the button text hasn’t changed: https://test.zedonk.net/better
sorry! i’m such an amateur!
the other thing that is totally bugging me is i’m trying to get a logo to appear in place of site title on homepage only.
using this code in child css i have been able to replace title with image but its applying it to all pages and i’ve been trying and trying to figure out how to restrict to homepage, to no avail:
.site-title a {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
background: url(https://test.zedonk.net/wp-content/uploads/2015/08/ZEDONK_RGB-300×97.jpg) center no-repeat;
background-size: 100%;
display: block;
margin: 0 auto;
width: 300px;
height: 97px;
}Hi again Zedonk!
I include a link to a child theme I have created for you. Download that and activate it. https://www.dropbox.com/sh/r8aab21sx16f7yr/AADM53FIqoVGZg4UzJiznzzva?dl=0
Hope that helped you out.On your other problem. Try adding the class selector of “home” in front to select only the home page.
Like this:
.home .site-title a { text-indent: 100%; white-space: nowrap; overflow: hidden; background: url(https://test.zedonk.net/wp-content/uploads/2015/08/ZEDONK_RGB-300x97.jpg) center no-repeat; background-size: 100%; display: block; margin: 0 auto; width: 300px; height: 97px; }
Cheers
?yvind
[Signature moderated]touchcoding that is so kind of you!!
got the .home image sorted. thanks.
have downloaded the files but got in a right muddle when i tried to activate. where exactly should i save them? Directly in the /themes/intergalactic-child02 folder? also, i already have a child theme css file in there, which makes some minor adjustments. what should i do with your new css code, append it?
If you already have I style.css, just copy your css into the child theme I provided and that should keep your css changes.
Yes, just copy the folder into /wp-content/themes folder and activate the theme.
Replacing the contents in Previous and Next in child-theme/inc/template-tags.php did not work for me.
To get this to work I pulled the template-tags file by requiring the file via child-theme stylesheet directory
require get_stylesheet_directory() . '/inc/template-tags.php';
Once this was complete I did a search and replace for all instances of
intergalactic_stuff
withmy_new_stuff
and lastly changed the same in my child-theme/content-single.php,new_post_nav();
on line 28 I believe.Follow these exact steps and you will be able to customize any part of the template-tags.php without errors. Nothing will change until you update the
intergalactic_
references toyour_new_
in the child theme.
- The topic ‘change font navigation text’ is closed to new replies.