How can i edit this to just print out Copyright © 2017. All Rights Reserved. I keep getting an error on the last curly bracket when the second part of the function is removed and i can't figure it out.
*/
function nepalbuzz_get_content() {
$theme_data = wp_get_theme();
return sprintf( _x( 'Copyright © %1$s %2$s. All Rights Reserved', '1: Year, 2: Site Title with home URL', 'nepalbuzz' ), date_i18n( __( 'Y', 'nepalbuzz' ) ), ''. esc_attr( get_bloginfo( 'name', 'display' ) ) . '' ) . ' | ' . $theme_data->get( 'Name') . ' ' . esc_html__( 'by', 'nepalbuzz' ). ' <a target="_blank" href="'. $theme_data->get( 'AuthorURI' ) .'">'. $theme_data->get( 'Author' ) .'</a>';
}
I have edited to this:
function nepalbuzz_get_content() {
$theme_data = wp_get_theme();
return sprintf( _x( 'Copyright © %1$s %2$s. All Rights Reserved', '1: Year, 2: Site Title with home URL', 'nepalbuzz' ), date_i18n( __( 'Y', 'nepalbuzz' ) ), ''. esc_attr( get_bloginfo( 'name', 'display' ) ) . '' ) ; }
But I am still getting an unexpected syntax. Thanks for your time in advance!
You may just need to escape your double quotes.
function nepalbuzz_get_content() {
$theme_data = wp_get_theme();
return sprintf( _x( 'Copyright © %1$s %2$s. All Rights Reserved', '1: Year, 2: Site Title with home URL', 'nepalbuzz' ), date_i18n( __( 'Y', 'nepalbuzz' ) ), ''. esc_attr( get_bloginfo( 'name', 'display' ) ) . '' ) ; }
Related
my problem is very simple but I am not familiar with PHP. My goal is to change the date format for the comments in my Wordpress blog from "26th of February 2021 at 12:23" to "43 minutes ago".
I also found a code snippet that does this for me, but it doesn't render the markup like the code which is provided by the theme itself.
This is the code provided by Astra:
printf(
'<div class="ast-comment-time ast-col-lg-12"><span class="timendate"><time datetime="%2$s">%3$s</time></span></div>',
esc_url( get_comment_link( $comment->comment_ID ) ),
esc_attr( get_comment_time( 'c' ) ),
/* translators: 1: date, 2: time */
esc_html( sprintf( __( '%1$s at %2$s', 'astra' ), get_comment_date(), get_comment_time() ) ),
);
This is the code I found:
printf( _x( '%1$s ago', '%2$s = human-readable time difference', 'wpdocs_textdomain' ),
human_time_diff( get_comment_time( 'U' ),
current_time( 'timestamp' )
);
I'd be more than happy if someone could help me with this since I don't know where to search for a solution anymore...
Thank you all!
This revision to your code may work as desired:
printf(
'<div class="ast-comment-time ast-col-lg-12">
<span class="timendate"><time datetime="%2$s">%3$s</time>
</span>
</div>',
esc_url( get_comment_link( $comment->comment_ID ) ),
esc_attr( get_comment_time( 'c' ) ),
esc_html( __( human_time_diff( get_comment_time( 'U' ) ) . ' ago', 'astra' ) )
);
I need some help in php. I need an hyperlink on the phrase inetio s. r.o.
The code is following:
if ( function_exists( 'get_the_privacy_policy_link' ) ) {
$footer_text = sprintf( _x( 'Copyright © %1$s %2$s. Všechna práva vyhrazena. %3$s', '1: Year, 2: Site Title with home URL, 3: Privacy Policy Link', '' ), esc_attr( date_i18n( __( 'Y', '' ) ) ), ''. esc_attr( get_bloginfo( 'inetio', 'display' ) ) . '', get_the_privacy_policy_link() ) . ' | ' . esc_html( $theme_data->get( 'inetio s. r. o.') ) . ' ' . esc_html__( 'vytvořilo inetio s. r. o.', 'solid-construction' ). ' <a target="_blank" href="'. esc_url( $theme_data->get( '' ) ) .'">'. esc_html( $theme_data->get( '' ) ) .'</a>';
}
Thanks for any help
boza
You can use it under WordPress built-in hook for this purpose.
add_action('wp_footer','dev_testing_func');
function dev_testing_func(){
/*Place your Code here*/
}
I'm very new to Php. I want to show the Last Updated date instead of the Published time. Can someone help me? Thank you very much.
if ( ! function_exists( 'minimalistblogger_posted_on' ) ) :
function minimalistblogger_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(
esc_html_x( 'Posted on %s', 'post date', 'minimalistblogger' ),
'' . $time_string . ''
);
$byline = sprintf(
esc_html_x( 'by %s', 'post author', 'minimalistblogger' ),
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
);
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.
}
endif;
Ah! I found it!
Just use the
get_the_modified_time('F d, Y');
$modifiedtime = get_the_modified_time('F d, Y'); $posted_on = sprintf(
esc_html_x( 'Last modified on %s', 'post date', 'minimalistblogger'
), '' .
$modifiedtime . '' );
thank you :)
i try to write a simple code for php, which can show date,post autho and category but i can not show category. Where can i add it? this is code:
$posted_on = sprintf(
esc_html_x( 'Posted on111 %s', 'post date', 'sanse' ),
'' . $time_string . ''
);
$byline = sprintf(
esc_html_x( 'by %s', 'post author', 'sanse' ),
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
);
Inside have_posts loop you can use get_the_category() function to display posts' categories.
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo '' . esc_html( $categories[0]->name ) . '';
}
https://developer.wordpress.org/reference/functions/get_the_category/
I am currently developing a WordPress site and would like to know what to change in the template-tags.php file to remove the date, time and author name.
Here is the code which I believe I need to change although each time I do I am greeted with the dreaded screen of death.
if ( ! function_exists( 'makewp005_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function makewp005_posted_on() {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) )
$time_string .= '<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() )
);
printf( __( '<span class="posted-on">%1$s</span> <span class="byline"> %2$s</span>', 'makewp005' ),
sprintf( '%2$s',
esc_url( get_permalink() ),
$time_string
),
sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s">%2$s</a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author() )
)
);
}
endif;
Thanks!
Why don't you use the CMS / API to remove them?
I believe this is the option to remove post info;
Larger: http://puu.sh/8rzux.png
So basically you want remove everything this function does.
if ( ! function_exists( 'makewp005_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function makewp005_posted_on() {}
endif;