Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • You could achieve this using worpdpress shortcode api.
    Create a shortcode which will return the links with the dynamic parameter.
    Then you can use the shortcode where needs to be used.

    Here is an example. creating a shortcode [user_data_link]

    <?php
    // Function to generate link with user data
    function generate_link_with_user_data_shortcode() {
        // Retrieve the current user's data
        $current_user = wp_get_current_user();
        $user_data_value = get_user_meta($current_user->ID, 'your_custom_field_name', true); // Change 'your_custom_field_name' to the actual meta key of your custom field
    
        // Construct the link with the user data value
        $link_url = home_url('/page?VALUE=' . urlencode($user_data_value));
    
        // Return the link HTML
        return '<a href="' . esc_url($link_url) . '">Link with User Data</a>';
    }
    // Register the shortcode
    add_shortcode('user_data_link', 'generate_link_with_user_data_shortcode');
    ?>
    
    // Add custom meta box
    function custom_post_category_dropdown_meta_box() {
        add_meta_box(
            'custom-post-category-dropdown',
            __('Post Category Dropdown', 'textdomain'),
            'custom_post_category_dropdown_meta_box_callback',
            'post', // change to your post type if needed
            'side',
            'default'
        );
    }
    add_action('add_meta_boxes', 'custom_post_category_dropdown_meta_box');
    // Meta box callback function
    function custom_post_category_dropdown_meta_box_callback($post) {
        // Fetch categories with posts
        $categories = get_categories(array(
            'hide_empty' => 0,
            'orderby' => 'name',
            'order' => 'ASC'
        ));
    
        // Dropdown list HTML
        echo '<label for="custom-post-category">Select Category:</label><br>';
        echo '<select id="custom-post-category" name="custom_post_category">';
        echo '<option value="">Select Category</option>';
        foreach ($categories as $category) {
            echo '<option value="' . $category->slug . '">' . $category->name . '</option>';
        }
        echo '</select>';
    }
    // Save custom meta box data
    function save_custom_post_category_dropdown_meta_box_data($post_id) {
        if (array_key_exists('custom_post_category', $_POST)) {
            update_post_meta(
                $post_id,
                '_custom_post_category',
                $_POST['custom_post_category']
            );
        }
    }
    add_action('save_post', 'save_custom_post_category_dropdown_meta_box_data');

    Hope this will serve the purpose, if you php and wordpress knowledge you can customize as your need/

    Hello, Please make sure your Mobile Dropdown -> Fullwidth is set to yes.

    See This: https://prnt.sc/du4AKvn4HlG3

    https://elementor.com/help/nav-menu-widget-pro/#additional-use-cases

Viewing 3 replies - 1 through 3 (of 3 total)