3

I have used a theme that includes the word "courses" throughout the theme by default as it is an online education platform. I am however creating a website with a similar design, but for projects so i would like to replace the word "courses" throughout the theme with the word "projects" I have minimum experience with coding and even html so please dumb it down for me :) Thank You in advance

4 Answers 4

7

I see some great answers for how to do a search and replace on a given string found in the database. However as I understand the OP's question, they are looking to replace text found in the theme files, as the question says "I have used a theme that includes the word "courses" throughout the theme by default...".

If this was a case where the theme anticipated this need, or was already changing the text of a plugin, like some themes change the WooCommerce cart text from "add to cart" to "purchase course". Then there would be filter hooks available but you would need well written documentation, or the ability to look through the code to determine this. (https://developer.wordpress.org/reference/functions/add_filter/)

A fast simple clever way would be to add this to a child theme's functions.php file. (https://codex.wordpress.org/Child_Themes)

function start_modify_html() {

    ob_start();
}

function end_modify_html() {

    $html = ob_get_clean();
    $html = str_replace( 'Course', 'Project', $html );
    $html = str_replace( 'course', 'project', $html );
    echo $html;
}

add_action( 'wp_head', 'start_modify_html' );
add_action( 'wp_footer', 'end_modify_html' );

The last way would be to edit the theme files, if the theme were ever updated all of your changes would be lost. To do this you could download the theme and use any decent text editor to do a search and replace, then upload. I do this with Atom editor all the time and it is open source and free to download. (http://flight-manual.atom.io/using-atom/sections/find-and-replace/)

1
  • This is the better option by far....
    – Brethlosze
    Jan 22, 2019 at 3:18
2

I would try one of two options depending on your preference

1. Search & Replace Script

You can click the dry run button under actions to see what it will be replacing before you execute the script. Once you're done be sure to remove the /replace/ folder.

2. Search & Replace Plugin

For a similar process, but within WordPress, is to use the Search & Replace plugin to easily update your database that contain the word "courses" and change it to "projects". The process is easy to use and you can also perform a dry run to preview what tables and rows will be affected before applying those changes.

1

If you have WP-CLI you can do a "dry run" to see what would change.

wp search-replace courses projects --dry-run

Example output:

| wp_posts | post_content | 6 | SQL |

In example, 6 occurrences of courses in wp_posts table would be replaced with projects

See Search/replace strings in the database for more info.

-1

The simplest thing you can do is export the database and find/replace courses with projects, save it and import the updated file to your server.

Or else You can try this plugin which replaces words(though i haven't got chance to try it) https://wordpress.org/plugins/word-replacer/

Let me know if you need any help further

2
  • 1
    I would caution the first option. If the whole theme is built around courses, doing a database find/replace might to more damage than good, since you don't know what links or other elements might be adversely effected. Sep 10, 2016 at 14:34
  • But thats what you asked right ? You said you want to replace through out your theme
    – Zeeshan
    Sep 10, 2016 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.