• Resolved whatevaitis

    (@whatevaitis)


    Hi all. I’m running MH Magazine Lite v2.6.4.

    I don’t want the entry dates on the main blog post list, on individual post pages, in post widgets, and wherever else they may appear to link to anything at all. I still want to display the post date in all of those locations, but just as regular text.

    I found this code in mh-custom-functions.php:

    echo '<span class="entry-meta-date updated"><i class="fa fa-clock-o"></i><a href="' . esc_url(get_month_link(get_the_time('Y'), get_the_time('m'))) . '">' . get_the_date() . '</a></span>' .

    I don’t know if adjusting this will affect the change in all the post locations I listed above, but if anyone can tell me how to change this code, I can figure out all the places I need to change it.

    This is the correct code to edit, yes?

    Thanks

    • This topic was modified 7 years, 9 months ago by whatevaitis.
    • This topic was modified 7 years, 9 months ago by whatevaitis.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi whatevaitis,

    thanks for using MH Magazine lite.

    Yes, the linked date is handled by the function mh_magazine_lite_post_meta() within the file mh-custom-functions.php and you can modify this function as you like. Just make sure that you don’t edit core theme files but code your customizations in a custom child theme instead.

    Thread Starter whatevaitis

    (@whatevaitis)

    Can you tell me how to change the code so the dates still appear but are not linked?

    Thanks.

    You could do something like this:

    echo '<span class="entry-meta-date updated"><i class="fa fa-clock-o"></i>' . get_the_date() . '</span>' . "\n";

    However, as mentioned, make sure that you don’t edit core theme files on your live site. Otherwise your code modifications will be lost after theme updates anyway and you’ll also break your site if you make a mistake (e.g. syntax error).

    Instead you should code a custom child theme which contains your code modifications. If you’re not familiar with coding, you may want to consider hiring a freelance developer for the job.

    Thread Starter whatevaitis

    (@whatevaitis)

    That did the trick, thanks!

    Unfortunately, because I can modify but not write code, and because I’m broke, I have to modify the theme each time I update. I know, it’s a horrible way to do things.

    If I could just copy my modified style.css to a child, I would be fine. But If i understand correctly, it’s not that simple.

    Thank you for your help.

    Thread Starter whatevaitis

    (@whatevaitis)

    Can I just copy the modified lines from my modified style.css to a child theme’s style.css? Or would that just conflict with the parent? I don’t know if special code is needed for child themes.

    I have redundant backups of everything, including all of my modifications. If I can update MH Magazine, create a child, then just copy the relevant changes from my backups to the child theme’s files, then that’s something I need to do this weekend.

    Thank you for your help. I appreciate it and understand that I’m pushing this thread far outside the realm of MH support. Plus, I’m a free user. So I’ll understand if there is no reply. ??

    Thanks

    Can I just copy the modified lines from my modified style.css to a child theme’s style.css?

    Yes, that’s the purpose of a child theme. But the style.css file is only for CSS code. If you want to modify PHP code, you need to copy the original function from the parent theme into the file functions.php of the child theme (if the function is pluggable) and modify it there. Here you can learn more:

    So I’ll understand if there is no reply.

    No worries and have a nice weekend. ??

    Thread Starter whatevaitis

    (@whatevaitis)

    Thank you! I transitioned to a child theme today and it wasn’t as bad as I thought it would be. A few tweak here and there and I’m good to go – apart from mods I made to php files.

    I’ll have to do some research to learn about pluggable functions. Sounds like just copying the entirety of a php file would be bad, because I wouldn’t be getting new code from updates.

    I’ll see what I can get away with.

    You have a great weekend as well.

    Thread Starter whatevaitis

    (@whatevaitis)

    Absolutely everything is working as I had hoped except one thing: the topic of this thread – removing linking from the dates on post pages.

    The code you provided for mh-custom-functions.php worked when I modified the the primary theme, but I can’t seem to get the child to use the modified mh-custom-functions.php. I did create the includes folder in my child theme directory and put the file in there. The group and ownership are correct.

    I’ve read this method generally only works for template files and not for functions files. I don’t want to be a hassle and you’ve already helped a lot. But is there a quick solution to get this mh-custom-functions.php code working in my child theme?

    
    echo '<span class="entry-meta-date updated"><i class="fa fa-clock-o"></i>' . get_the_date() . '</span>' . "\n";

    The code you provided for mh-custom-functions.php worked when I modified the the primary theme, but I can’t seem to get the child to use the modified mh-custom-functions.php. I did create the includes folder in my child theme directory and put the file in there. The group and ownership are correct.

    Please have a look at the previous reply. You need to copy the function mh_magazine_lite_post_meta() (which is pluggable) into the file functions.php of your child theme and modify it there. Creating an includes folder in your child theme won’t work, unless you refer in functions.php to the correct file.

    Thread Starter whatevaitis

    (@whatevaitis)

    Oh, thank you much. Kind of fumbling my way through some of this stuff, but It’s all working now.

    I really appreciate your time. And your theme! It’s really great.

    You’re very welcome. By the way, if you like the theme, then it would be nice if you could quickly rate it here. Thanks and have a nice weekend! ??

    Thread Starter whatevaitis

    (@whatevaitis)

    Reviewed 5 stars. Thank you.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘mh-custom-functions.php – change post date from link to standard text’ is closed to new replies.