Archived topic
Make post date not clickable
10 replies · Started by Steig on April 25, 2019
Hello,
I'd like to make it so that the post date isn't clickable. Is that possible?
Thanks!
Let's make it so the author isn't clickable either.
To remove it from the date, this should help: https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date
For the author: https://docs.generatepress.com/article/generate_post_author_output/#remove-link
Hope this helps :)
I've put both those into the simple css window and they aren't removing the links.
Hi there,
that code is PHP. This article explains ways to add that:
https://docs.generatepress.com/article/adding-php/
It contains a link to the Code Snippets plugin which is easiest method if you don't have a child theme.
I'm running a child theme and put that code into functions.php. The result has removed clickability, but the post date is shown twice, back to back.
<?php
/**
* GeneratePress child theme functions and definitions.
*
* Add your custom PHP in this file.
* Only edit this file if you have direct access to it on your server (to fix errors if they happen).
*/
function generatepress_child_enqueue_scripts() {
if ( is_rtl() ) {
wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
}
}
add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 );
/* remove link from date */
add_filter( 'generate_post_date_output','tu_remove_date_link', 10, 2 );
function tu_remove_date_link( $output, $time_string ) {
printf( '%s',
$time_string
);
}
/* remove link from post author */
add_filter( 'generate_post_author_output', function() {
printf( ' %1$s',
sprintf( '%1$s %4$s',
__( 'by','generatepress'),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ),
get_the_author() ) ),
esc_html( get_the_author() )
)
);
} );
Do you have any other custom functions on the site? Using the Code Snippets plugin maybe?
The only other customization I'm aware of what changing the content.php file as follows:
<?php
/**
* The template for displaying posts within the loop.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
<div class="inside-article">
<?php
/**
* generate_before_content hook.
*
* @since 0.1
*
* @hooked generate_featured_page_header_inside_single - 10
*/
do_action( 'generate_before_content' );
?>
<header class="entry-header">
<?php
/**
* generate_before_entry_title hook.
*
* @since 0.1
*/
do_action( 'generate_before_entry_title' );
the_title( sprintf( '<h2 class="entry-title" itemprop="headline"><a class="sg-iframe-popup-133" href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header><!-- .entry-header -->
<?php
/**
* generate_after_entry_header hook.
*
* @since 0.1
*
* @hooked generate_post_image - 10
*/
do_action( 'generate_after_entry_header' );
if ( generate_show_excerpt() ) : ?>
<div class="entry-summary" itemprop="text">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content" itemprop="text">
<?php
the_content();
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<?php endif;
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
</div><!-- .inside-article -->
</article><!-- #post-## -->
This was to make it so that each post detail page shows as a popup.
It looks like the functions you added in your child theme are missing various elements from the examples on the pages I linked you to. Can you re-add them and make sure everything looks the same?
That did it; sorry about that.
No problem! :)