Can we change "#comments" from URL in the Wordpress theme - php

In my Wordpress site, all the contents of URL in my language, Turkish. When I want to link to a page's comments, I have to write it like this: http://siteadi.com/icerigin-basligi/#comments. I don't mind normally, but I don't want URL, a part of it to be in Turkish and some in English. So I want to change #comments with #yorumlar in the theme.
I know, we can do this with changing get_comments_link() function in the wp-includes/comment-template.php. But I think, this is not a good solution, because if the theme is updated, the edited content will also be deleted. So I want to do this with the theme page. Is it possible or do I have to do it in wp-includes/comment-template.php?

Do never edit core files
(located in /wp-includes, /wp-admin etc.) . Do not do it! (https://wordpress.stackexchange.com/questions/1639/what-are-some-reasons-why-you-should-not-hack-wordpress-core-files).
If you are using a ready-bake theme then you have to create a child theme (https://codex.wordpress.org/Child_Themes), copy the comments.php file from your main theme into it and change id="comments" to id="yorumlar".
<div id="yorumlar" class="comments-area">
This way you can still update your theme without destroying any changes.
If you have developed a theme yourself just change the name of the ID in comments.php to your needs.
Note: In a multilanguage page HTML IDs are usually not translated as this causes problems with CSS, JavaScript and anything else. An HTML ID / anchor is a technical thing which should be language independent while usually english is used as global internet default language (last but not least because of the ASCII charset).

Related

Multilingual WordPress with redirects and dynamic content

Not sure how to title my issue.
I have a Wordpress website, where most values are stored in custom fields and is very independent of language - e.g. most values are numbers.
Instead of creating a multi-site with several network sites, I am looking for a much simpler solution. Let's say I want to create a German version. Then ideally, I could redirect all German users accessing the site with /de/ to a German version of the theme.
E.g.:
http://www.example.com/post-name/ directs to single.php in the theme files
http://www.example.com/de/post-name/ directs to single-de.php in the theme files. So they will have the same content, but the translation will be in the theme file.
The only problem I can see is the canonical URL, but I am guessing this can be dealt with as well. So my question is, is it possible to redirect all users that go to /subfolder/post-name/ to a specific theme file and display the content of that post with the specific theme file?
Is there any solution I have missed that might be easier?
My solution above would only require redirects and some additional theme files instead of creating a completely new multi-site and importing everything and having to keep this site updated as well.
There is already wp logic to do theme translations, so you don't need to re-invent that. If your content is in the theme or is the same for all languages (eg the numbers), then the translations should work well for this.
One can set WP-LANG dynamically. Viper's https://wordpress.org/plugins/in-their-language/ tries to do that automatically for admin area (not sure if it still works), or/and you could add a language switcher. Fairly easy, there's a variety out there https://www.google.com/search?q=wordpress+language+switcher.
this is an answer to
Is there any solution I have missed that might be easier?
not an answer to
So my question is, is it possible to redirect all users that go to
/subfolder/post-name/ to a specific theme file and display the content
of that post with the specific theme file?

Is it possible to hook a text box into a WordPress theme, via the functions.php file?

I am currently using a WordPress theme to create an ecommerce website. I am looking to create a horizontal text box, with 3 columns, to appear directly beneath the Main Menu navigation. Rather than edit the header.php file, and risk breaking the theme, is it possible to achieve this by hooking into the theme, via a functions.php file in the child theme or would thus be bad practice?
So adding "right after the main menu" is not something WordPress will be able to give you directly, no. Because, by definition, the structure of a page is a theme's responsibility.
That would be a perfect case for a child theme, and it would be my first choice. There you can safely override the index file (or header file, depending on how the theme is built) and add your html to it.
Another option a child theme might give you, is adding html through the theme's own filters and actions - but that will totally depend on your theme giving you such hooks.
Finally, if truly you want to add right after the main navigation, you might look at the wp_nav_menu filter: using that, it should be possible to first detect if you are looking at the main navigation or not, and if you are, append your own html. But frankly, I think the risk of breaking your layout is greater with that method.
Hope this helps!

Wordpress lost link after theme update. [Enfold Theme]

I'm by no means a coder or programmer but i have enough to understand my part and fix small issues or adjust look with basic CSS, and so friend of mine asked me for help and here i am two days later asking you)
There is a Website running Enfold theme which recently were updated and so was lost custom image link at right part of header made by someone-else.
I have restored link code from Cached version of website but have no real understanding how and where to add it back to theme templates. Would appreciate any help, solution, link, advice.
Cheers.
A wild guess, since I don't have Enfold theme (the best would be to ask on the official support), but in your div #header_main in the .inner-container, you had after the #advanced_menu_toggle this piece of code:
<img src="http://vcmt.ca/wp-content/themes/enfold/images/layout/canvas.jpg" alt="canvas" style="max-height:70px;">
Just open the .php file that has the header in it, and paste this code back in. Since the canvas.jpg was located in the /images folder of the theme, that is also gone, so my recommendation is to download the image from the cached version if you can and put it back in the image folder.
Also it would be better to make changes to child theme, so that you can update the functionality of the theme, without loosing any custom added modification, like this site had.
If you're planning on changing the CSS in any WordPress Theme, you want to make sure that you have a child theme installed. The child theme allows you to change/overwrite the CSS and Theme Functions on the theme without losing those changes everytime the theme updates.
You can download the Enfold Child Theme Here:
https://kriesi.at/documentation/enfold/how-to-install-enfold-theme/#why-child-theme
...and if you need to add HTML to the header, you can do so by duplicating the header file from the theme, adding a header file to the child theme, and making your changes in the child theme header file.
Hope this Helps!

How do I customize content in the WP starter theme Roots?

I am fairly new to WP and very new to Roots (http://roots.io/) and I am having trouble creating a custom home page. Here's how far (I think) I understand it:
To create a custom home page I put a file named "front-page.php" in the WP root directory. This file is based off of "page.php".
"front-page.php" loads "content-page.php" from the templates directory.
And that's where it gets a bit fuzzy to me. The function "the_content()" lives in "content-page.php" and I'm assuming it loads the content of the page but it's loading some default stuff (I think it's added by the Roots theme) that I don't want there. I don't think the proper way to customize the home page content is to modify "content-page.php" and remove or change the function "the_content()". I'm assuming there is a better, modular way to do this, possibly creating a custom class that will be loaded when "the_content()" is called but I don't know where and how to do that.
As you're a bit vague with the details I'm going to have to read between the lines a bit. If you need further clarification just ask:
the_content() just outputs the content stored for a particular post, which you would edit in the WP admin. In terms of editing the markup that surrounds the content you have a couple of options. You could edit content-page.php as you require, or create a new partial (such as content-home.php and load that instead.
You can also use filters for modifying content; these are often used to change content that appears in multiple places such as 'read more' links. Check out this introduction to filters for more info.
In closing, you don't want/need to edit the_content()

wordpress use in own template

I've created an HTML page as part of my website which I would like to use as a template for news articles. The page has all the things it needs, it just needs to display the correct news article in it.
I installed WordPress on my webserver and now wonder how I can have wordpress publish articles using my HTML page?
Is this even possible since WordPress works with php?
thanks
What you are talking about is themes. Wordpress allows you to create a theme for your installation so it displays using your html/css (more or less)
The way I do this is copy the default theme and make changes in there, and then you can switch to your new theme in your settings.
Edit: in addition, you can also load up wordpress on any page using:
include( '/path_to/wordpress_install/wp-load.php' );
This will allow you to use wordpress functionality on any page of your site.
just edited the single.php file by pasting the desired html code and leaving the loop code there where the text needed to show up.
didn't need to break up the page in a header, body and footer. Left out sidebar for now, but will put it back after I edit it properly.

Categories