Customizing Child Themes and Templates:

In this guide, we’ll delve into the process of customizing the default templates of Advanced Classifieds and Directory Pro plugin, along with creating theme files for the custom post types associated with it.

Replacing Default Templates:

Why replace default templates? Sometimes you might find the default layout provided by the Advanced Classifieds and Directory Pro plugin doesn’t perfectly fit your specific needs or niche. While you could directly edit the plugin files, this is strongly discouraged as it could lead to your changes being overwritten during updates. Instead, we recommend utilizing the ‘acadp_load_template’ filter.

First, let’s take a look at the default template files provided by the plugin, located in the ‘advanced-classifieds-and-directory-pro/public/templates’ directory. These include templates for categories, listings, locations, payments, registration, search, and user management, among others.

Using the ‘acadp_load_template’ Filter:

To customize a specific template, let’s say we want to add some additional text above the Listings grid layout. Here’s how we can achieve this:

Create a folder named ‘acadp-custom’ inside the ‘wp-content/plugins’ directory.
Inside this folder, create a file named ‘acadp-custom.php’ and add the below PHP code to override the templates. This code should include a function hooked into the ‘acadp_load_template’ filter, which checks for custom template files and loads them if they exist.

<?php
/*
 * Plugin Name:    ACADP – Custom
 * Plugin URI:     https://pluginsware.com
 * Description:    Overrides "Advanced Classifieds & Directory PRO" plugin templates.
 * Author:         Team PluginsWare
 */

// Exit if accessed directly
if ( ! defined( 'WPINC' ) ) {
	die;
} 

function acadp_custom_templates( $tpl )  {
    $custom_tpl = dirname( __FILE__ ) . '/templates/' . basename( $tpl );

    if ( file_exists( $custom_tpl ) )  {
        return $custom_tpl;
    }
        
    return $tpl;
}

add_filter( 'acadp_load_template', 'acadp_custom_templates', 11 );

Additionally, create a custom template file, such as ‘layout-grid.php’, inside the ‘acadp-custom’ directory. In this file, add your custom content and include the default template file to maintain the original structure.

<?php
printf( 'Today is %s.', date( 'Y-m-d' ) );
include ACADP_PLUGIN_DIR . '/public/templates/listings/layout-grid.php';

You can download the complete working example from here

After activating the ‘ACADP – Custom’ plugin from the WordPress Admin Panel, the custom text should now appear above the listings grid.

When it comes to displaying the details of a single listing page, your theme typically utilizes the ‘single.php’ file. However, there might be instances where you want to customize the layout or content specifically for these pages.

To create a custom template for single listing pages:

1. Navigate to your theme directory via FTP.

2. Create a new file named ‘single-acadp_listing.php’.

3. Copy the contents from ‘single.php’ (or ‘page.php’) into this file and make any necessary modifications.

Now, when a single listing page is loaded, WordPress will prioritize the ‘single-acadp_listing.php’ template. Using hooks like ‘the_content’, you can then include the default template file (‘single-listing.php’) provided by the plugin to ensure the proper display of listing details such as title, description, category, etc.

By following these steps, you can seamlessly customize the templates and child themes associated with Advanced Classifieds and Directory Pro to better suit your needs.

Note:

For users utilizing plugin versions earlier than 3.0 or implementing custom bootstrap designs, we kindly advise referring to our documentation on customizing ACADP templates available at https://pluginsware.com/documentation/customize-acadp-templates/. This resource offers comprehensive guidance for tailoring your ACADP templates to suit your specific needs and preferences.