Change the URL of List a Service button

In some ealier topics, it was advised that we can change the URL associated to List a Service by using the below code snippet in the functions.php file of the child theme.

// Set a temporary slug for the "Submit Listing" page
add_filter('hivepress/v1/routes', function($routes) {
    $routes['listing_submit_page']['path'] = '/example';
    return $routes;
}, 1000);

However, this also deletes the option to access the /submit-listing/details/ page.

Basically, I want the button in the navbar/header section to redirect to another page, but I still want users to access the /submit-listing/details/ from other buttons on my website, which becomes impossible once I use the code snippet above.

Would you be able to assist? How do I change the URL of the List a Service button without entirely deleting the /submit-listing/details/ page?

Hi,

The snippet looks fine. Please make sure that after adding the snippet, you didn’t forget to update your permalinks.

Could you please explain what you mean by updating the permalinks? Many thanks in advance!

Please refer to this article on How to refresh WordPress permalinks - HivePress Help Center.

In short, please go to WP Settings > Permalinks and click the Save button.

Hope this helps

Hi again,

It didn’t work.

I copied the listing-submit-link.php file into my child theme (kept the same folder structure: meetinghive_child / listing / submit).

I replaced the content of the original listing-submit-link.php file with the below code, as I want to button to redirect to the “/new-listing” page.

<?php
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

if ( get_option( 'hp_listing_enable_submission' ) ) :
	?>
	<button type="button" class="hp-menu__item hp-menu__item--listing-submit button button--primary" data-component="link" data-url="<?php echo esc_url( 'https://mywebsite.com/new-listing/' ); ?>">
		<span><?php esc_html_e( 'List a Service', 'meetinghive' ); ?></span>
		<i class="hp-icon fas fa-plus"></i>
	</button>
	<?php
endif;

The below code snippet, shared earlier, had no effect.

// Set a temporary slug for the "Submit Listing" page
add_filter('hivepress/v1/routes', function($routes) {
    $routes['listing_submit_page']['path'] = '/new-listing';
    return $routes;
}, 1000);

Kindly note that I did refresh the permalinks, but nothing seems to work.

Thank you,
Adrien

We tested the second snippet and it worked on our side.

Please make sure that you add the snippets correctly (in functions.php of your child theme or by using a code snippets plugin: Code Snippets – WordPress plugin | WordPress.org). In this case, it completely replaces the URL base of the listing submission pages.

If you’d like to change a button, please ensure that the path is correct: meetinghive_child/hivepress/listing/submit/listing-submit-link.php

Hope I helped with your request

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.