go top


  • Colection of 65 PHP scripts for $4.29 each

Get 65 PHP scripts in a bundle for $4.29 each!

View Offer

How to Add Our Listing Scripts to WordPress Websites?

by Kostadin Todorov /  Useful Resources

Integrating PHPJabbers scripts on WordPress

In view of the great number of customer requests for the integration of our classified ads scripts into WordPress websites, I decided to delve into the subject and give you both an insider perspective and a step-by-step guide to making this on your own.

Our listing scripts integrate with PHP include code since it is better for the website's SEO performance. This kind of code integration allows us to have URL rewrite and add meta tags to the listing details pages. URL rewrite is used to make the URLs search engine friendly and meta tags contain a short description of each of your web pages which is another key factor for your search engine rankings:

 A comparison of a long-tail and obscure URL address and a short and clean URL address


The problem is that you cannot add the PHP include code from the script to a WordPress website. It just doesn't work. Content management systems such as WordPress (and many others) are also written in PHP. WordPress is a big and complex system and if you allow any code to be executed within, this will lead to unexpected problems. There will be collisions, wrong paths, variables and functions that overwrite, problems with the URL rewrite, server sessions and many others. Even for an experienced PHP developer, it will be hard to solve all these problems and some of them might not have a solution at all. And what if the developer is new to PHP and causes more problems than solving them? This is the reason why WordPress developers have tried to protect their system from using third-party code. From their point of view, it is perfectly understandable that WordPress generally does not allow other PHP code to be included in its elements. Of course, they have offered some flexibility.


One option is to edit the template PHP code directly, but this still means that you have to comply with WordPress code. If you add code that uses the WordPress functions, it will all be fine, but it does not work for our scripts. Our scripts are not specifically written for WordPress because this would make them unusable on all other websites. We also cannot add our PHP code directly to the WordPress template pages because it causes all aforementioned collisions. We need to modify the header and footer of the page and since this is one system with one entry point and includes files for header and footer, making changes to it means altering the entire website. In the first place, this may easily break your WordPress website. Even if it works, eventually it will cause a delay in loading the whole website as some code will be loaded on every page, even if it is not needed there.


Another option are plugins that enable PHP code to be added, but this only works for very simple language statements. Our classified scripts are a lot more complex, they have many internal includes of files and parameters and such code cannot be managed directly by any of these plugins. Once such include is triggered from within WordPress, the path files are set according to WordPress location and folder structure and this means that the script cannot find its files.



Up until now we have offered the listing scripts to be included with iframe, but this is by far not the best option. Iframes are fixed height which means that the responsiveness of the script is lost. Since the script is loaded within the page, there might be scrollbars or big a empty space under the script (in case you set a big value for height to cover for the different frame height of the overall and listing pages). Iframes are also not good for your  SEO as the page URL is always the same and only changes within the iframe. This also means that there are no direct links to the listing details pages. All of this makes the script not especially useful. It shows the listings and does what it is supposed to, but content is generally hidden from the world.


Another solution we have proposed to our clients is that they make a separate page similar to their WordPress template. They just need to copy the raw HTML code and paste it on an empty file to make a separate PHP file that is linked from the WordPress menu to the website. This is a way better solution than iframe. The problem is that not every client can do this without external help. If you are a developer, it will be easy for you to make the new page, but when the end client starts using it and wants to change something, this page has to be updated manually each time. 


The Solution

After spending a lot of time trying to figure out how to help our clients with classified ads scripts that have to be added to WordPress websites we have finally come to the best possible solution. It still requires some manual work, but it’s as painless as it could be to make such a page. What we have done is creating a PHP file that implements WordPress and includes its header and footer, but also allows the script integration. We will guide you through a few easy steps how to add your listing script to WordPress:


Step 1. Make a PHP file that includes the script. Here attached is the PHP template that invokes the needed WordPress functions. All you have to do is add the tag for the script and the included file (again from the script).


Step 2. Set up your header in the WordPress template (optional).


Step 3. Upload this file to your server.


Step 4. Rename the __() function in our script with _stiva_()


This is necessary because there is a function with the same name __() in WordPress. You cannot redeclare a function, so the simplest solution is to rename this function in the script. It is used in many places so you will need some software that can search and replace in multiple files. There are many programs that can do this, so look for a such program online.


Step 5. Link this file to your WordPress menu.

Step 6. Set up the .htaccess file for SEO. You're ready!



Steps 1, 3 and 6 are the same as if you would add the script to a regular PHP website. The only difference is that you have to use the template we have attached, set up the header and that you have one extra step that links the menu from WordPress to this file.


Step 2 - Why is this optional?

Because setting the WordPress headers is a bit tricky and because meta tags actually do not have much of a use. It does not hurt to have them, but they are not important or even essential for quite some time already. Read more about it here.

Why is the header tricky to set up?

The reason is that WordPress has a very complex way to set up page header and there is a special build in the SEO module which handles it. Also many plugins are especially designed to be able to manage page headers. We do not want you to overwrite this functionality, so you should make your own header.php file. Here is what has to be done:

1. Check the theme that you are using in "Appearance" -> "Themes"

2. The theme is stored in its own folder under this path

"/wp-content/themes/[THEME FOLDER]/"

[THEME FOLDER] has a name similar to your "Theme" title in #1 above.

For example: If your theme is called "Twenty Seventeen", the folder will be "twentyseventeen".

3. Enter this folder and find header.php

4. Copy this file to the same folder and rename it to (for example)

"header-listing.php" (so you have two files header.php and header-listing.php)

(Please, note that the file must start with 'header-' and then some name of your choice.)

5. Open this new file and add the code for meta tags from our script to it. Add this line, too:

<?php remove_theme_support( 'title-tag' ); ?>

This will disable the default title that WordPress sets for your page. Since our script will now generate the title and meta tags, WordPress title is not necessary.

6. Open the template file we have provided and uncomment the line with get_header('listing');

The name in the brackets must be the same as the name after the dash in the file name you just created.

Comment the get_header(); line. That's it. You are ready to go!


In case you are not an advanced coder, we can add any of our classified ads scripts to your WordPress website. Just contact us and we will send you a quote!

Share on:

0 Comments to "How to Add Our Listing Scripts to WordPress Websites?"

Add your comment


    Please, be polite and helpful and do not spam or offend others! We promise you will be treated the same way!

    Log in to your account to post your comments. If you still haven't joined our community yet, you can create your FREE account now!

    Posting tip:
    If you use code in your comments, please put it in these tags [php], [sql], [css], [js] PHP code example: [php] echo date("Y-m-d"); [/php]

    Thank you,
    PHPJabbers Team