Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1378115

    Good morning everyone,

    I have installed the latest version of Enfold on my site, I would like to ask for your help in modifying a text string that is present before the author’s name in blog articles.

    In Italian it is translated as “da”, I think in the English version it is “from”, but in Italian it is not understood, it should be written differently (like: “di”, “scritto da”, “a cura di”).

    String before author

    How can I independently edit this string?
    Is it also possible to display it immediately below the title of the article?

    Thank you so much!

    #1378138

    In English, too, we would differentiate origin in the sentence

    I borrowed the book “Hamlet” by Shakespeare from John.

    So if you have f.e. portfolios that present books – and the author should now be named in the overviews – and not the creator of the article, then I’m not sure if this can be contextually differentiated.

    “Amleto” è di Shakespeare
    “Amleto” Ho preso in prestito il libro da John

    #1378165

    Yes I understand, I hope there is anyway a way to intervene in the code to fix it directly where it is needed, without having to change translations or anything else.
    I await kind help from the Enfold community.

    #1378174

    Hi,
    Thanks for your question, we could use javascript to change the “DA” to “DI” and move the line to under the title for Italian language blog posts,
    but we will need a link to a sample post to evaluate, please link to a post on your site.
    Also do you want the date and the author moved under the title, or just the author?
    I assume that you also want this moved in your other language too?

    Best regards,
    Mike

    #1378175

    Hi Mike!

    Thank you for your reply, I would only like to have the author at the top of the page (below the title of the article).

    The correction with “di” is fine, much better with “A cura di”.

    Here an EXAMPLE of my articles.

    #1378267

    Hi,
    Thanks for the link to your site the following function will move the author link on single posts up to under the title next to the category link and for Italian language posts change the “Da” to “A cura di”, it will also change this for your masonry grid on your /blog/ page.
    Add this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function move_author_and_replace_da() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
      var moveAuthor = document.querySelector('#top.single-post .post-meta-infos .blog-author.minor-meta');
      var appendtoDiv = document.querySelector('#top.single-post .post-entry .blog-categories.minor-meta');
      var authorBackslash = document.querySelector('#top.single-post .post-meta-infos .text-sep');
      if (!!moveAuthor) {
      var clone = moveAuthor.cloneNode(true);
      appendtoDiv.appendChild(moveAuthor).setAttribute('style','margin-left:10px');
      authorBackslash.setAttribute('style','display:none');
      }
    });
    (function($){
    $('html[lang="it-IT"] #top.single-post .post-meta-infos .blog-author.minor-meta').contents().filter(function() {
      return this.nodeType == 3
    }).each(function(){
      this.textContent = this.textContent.replace('da ','A cura di ');
    });
    $('html[lang="it-IT"] .av-masonry-author.meta-color.author').text(function(index, text) {
        return text.replace('da ', 'A cura di ');
    });
    })(jQuery);
     </script>
      <?php
    }
    add_action('wp_footer', 'move_author_and_replace_da');

    After applying, please clear your browser cache and check.
    Please see the screenshot in the Private Content area for the expected results.

    Best regards,
    Mike

    #1378272

    Good morning Mike!
    Thank you very much, the code works great!

    One question, is it possible to add a divider character (like ‘/’ ) between the category and “a cura di” under the article title?

    Kind of like it was originally at the bottom of the article, where there was a slash symbol between the date and the author’s name.

    Thank you for your time

    #1378309

    Hi,
    Please remove the above function so I can test and try again.

    Best regards,
    Mike

    #1378318

    Done, the coast is clear, you may proceed!
    One last thing, I saw that when the mouse cursor hovers over the author’s name in the new location, the colour of the link no longer changes (which it does now that it is back at the bottom of the article).
    Is there a possibility of retaining this function or not?
    It is not essential, you do not need to spend too much time on this.

    Thanks!

    #1378401

    Hi,
    Thanks for the feedback, since the author link is now in the categories span the hover color gray was the new color, so add this css to make the categories and author hover color blue like it was when it was below:

    .html_modern-blog #top.single-post div .main_color .blog-categories a:hover {
    	color: #88bbc8;
    }

    If you don’t want the categories to be blue on hover only the author try this css:

    .html_modern-blog #top.single-post div .main_color .blog-categories .author a:hover {
    	color: #88bbc8;
    }

    This is the new script to move the author link and the backslash:

    function move_author_and_replace_da() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
    var moveAuthor = document.querySelector('#top.single-post .post-meta-infos .blog-author.minor-meta');
    var appendtoDiv = document.querySelector('#top.single-post .post-entry .blog-categories.minor-meta');
    var authorBackslash = document.querySelector('#top.single-post .post-meta-infos .text-sep');
    if (!!moveAuthor) {
    appendtoDiv.appendChild(authorBackslash);
    appendtoDiv.appendChild(moveAuthor);
    }
    });
    
    var changeAuthorNode = document.querySelector('html[lang="it-IT"] #top.single-post .post-meta-infos .blog-author.minor-meta');
    if (!!changeAuthorNode) {
    changeAuthorNode.childNodes[0].replaceWith('A cura di ');
    }
    
    var changeMasonryAuthor = document.querySelector('html[lang="it-IT"] .av-masonry-author.meta-color.author');
    if (!!changeMasonryAuthor) {
    var search = "da ";
    var replacement = "A cura di ";
    document.body.innerHTML = document.body.innerHTML.split(search).join(replacement)
    }
    </script>
      <?php
    }
    add_action('wp_footer', 'move_author_and_replace_da');

    please clear your browser cache and check.

    Best regards,
    Mike

    #1378406

    Hi Mike,

    thank you very much for your help.
    The codes work perfectly and fit what I was looking for.

    Will they remain in the enfold updates or will I have to keep the backup of the function.php?

    Thank you!

    #1378411

    Hi,
    Glad to hear, if you are using a Child Theme and the code is in your child theme functions.php then it will work after each update, if it is in your parent theme functions.php and you don’t want to add a Child Theme try using the WPCode plugin and add the code as a “PHP snippet”.
    Let us know when you have this working and we will close this thread.

    Best regards,
    Mike

    #1378415

    Hi Mike,

    my theme is the main one.. Not child. Can I possibly install it now by exporting all the settings and reverting it to the child one without causing major disruption to the site?

    edit: I installed the child theme by exporting the settings from the main theme, it seems to work correctly.

    Thanks again for your support.

    • This reply was modified 1 year, 9 months ago by APcar.
    #1378430

    Hi,

    We are happy that Mike could help!

    Let us know if you have any other questions and enjoy the rest of your day :)

    Regards,
    Yigit

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Change string before author in blog article’ is closed to new replies.