I am having challenges centering the Navigation Inline element. Nothing seems to work, it’s stuck to the start of screen. How do I do this?
Hi Floyd,
Thanks for reaching out.
If you are adding it into the Container, you need to set the Horizontal attribute of Flexbox to Center to get the Navigation Inline in the center. Please find the screenshot describing the option.
Hope it helps.
Thanks
Hi Floyd,
You need to set the Flexbox values to the parent element of the Navigation Inline. So if you have added the Navigation Inline inside a Column, you need to set it to the column.
If that does not help, please provide login credentials for your site in a secure note to examine it further, including:
– WordPress Site URL & Login URL
– WordPress Admin username/password
– Specific Page where you have added it.
To create a secure note, click the key icon underneath any of your posts.
Thanks
I do not understand. I’m clueless.
Thanks!
Hi Floyd,
I have checked the specific page and the footer assigned to it, both are showing correctly, and the menu is centered.
If you are not seeing that correctly, there might be the cache behind your problem, I would suggest you check once by clearing all types of cache including the System Cache from Cornerstone > Settings > System > Clear System Cache, and check in the incognito/private mode of the browser.
If that is not the case and you are trying to point out something else, please provide any screenshot marked with the issue or any video that helps us to recognize the problem.
Thanks
Here’s the description I provided: (scroll to the bottom of the page, atop the bottom menus) See highlighted attached image.
Hello Floyd,
Your layout got complicated because you have added this in the custom.css file:
@media (max-width: 900px){
.post_row .x-row-inner{
flex-direction: column-reverse !important ;
}
.post_row .x-row-inner .x-col {
flex-basis:unset !important;
}
}
By the way, I noticed that you have added these PHP codes in the Pro theme’s functions.php file as well:
function my_custom_scripts() {
// Ensure jQuery is loaded (if your script depends on it)
wp_enqueue_script('jquery');
// Register and enqueue the custom.js script
wp_enqueue_script(
'custom-js', // Handle for the script
get_stylesheet_directory_uri() . '/assets/js/custom.js', // Path to the script
array('jquery'), // Dependencies (if any, e.g., jQuery)
null, // Version (set to null to avoid cache issues)
true // Load in footer (true for footer, false for header)
);
wp_localize_script('custom-js', 'myAjax', array(
'ajaxurl' => admin_url('admin-ajax.php') // URL to admin-ajax.php
));
}
// Hook the function to the wp_enqueue_scripts action
add_action('wp_enqueue_scripts', 'my_custom_scripts');
function register_diseases_conditions_post_type() {
$labels = array(
'name' => _x('Diseases & Conditions', 'Post Type General Name', 'text_domain'),
'singular_name' => _x('Disease/Condition', 'Post Type Singular Name', 'text_domain'),
'menu_name' => __('Diseases & Conditions', 'text_domain'),
'all_items' => __('All Items', 'text_domain'),
'add_new_item' => __('Add New Item', 'text_domain'),
'edit_item' => __('Edit Item', 'text_domain'),
'new_item' => __('New Item', 'text_domain'),
'view_item' => __('View Item', 'text_domain'),
);
$args = array(
'label' => __('Disease/Condition', 'text_domain'),
'description' => __('Post Type for Diseases and Conditions', 'text_domain'),
'labels' => $labels,
'supports' => array('title', 'editor', 'thumbnail', 'revisions'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'diseases-conditions/%disease_category%'),
);
register_post_type('diseases_conditions', $args);
}
add_action('init', 'register_diseases_conditions_post_type');
function register_disease_category_taxonomy() {
register_taxonomy('disease_category', 'diseases_conditions', array(
'label' => __('Disease Categories'),
'rewrite' => array('slug' => 'disease-category'), // Rewrite slug for the URL
'hierarchical' => true,
'public' => true,
));
}
add_action('init', 'register_disease_category_taxonomy');
function add_custom_diseases_conditions_rewrite_rules() {
// Add rule to handle URL without category
add_rewrite_rule(
'^diseases-conditions/([^/]+)/?$',
'index.php?post_type=diseases_conditions&name=$matches[1]',
'top'
);
// Add rule to handle URL with category
add_rewrite_rule(
'^diseases-conditions/([^/]+)/([^/]+)/?$',
'index.php?post_type=diseases_conditions&name=$matches[2]',
'top'
);
}
add_action('init', 'add_custom_diseases_conditions_rewrite_rules');
function custom_diseases_conditions_permalink($post_link, $post) {
if ($post->post_type == 'diseases_conditions') {
$terms = get_the_terms($post->ID, 'disease_category');
if ($terms && !is_wp_error($terms)) {
// Use the first category in the permalink if it exists
$term_slug = $terms[0]->slug;
return home_url('/diseases-conditions/' . $term_slug . '/' . $post->post_name . '/');
} else {
// If no category, return the post URL without the category
return home_url('/diseases-conditions/' . $post->post_name . '/');
}
}
return $post_link;
}
add_filter('post_type_link', 'custom_diseases_conditions_permalink', 10, 2);
function flush_rewrite_on_activation() {
add_custom_diseases_conditions_rewrite_rules();
flush_rewrite_rules();
}
add_action('after_switch_theme', 'flush_rewrite_on_activation');
require get_template_directory() . '/library/custom-functions.php';
function display_diseases_conditions() {
ob_start(); // Start output buffering
?>
<div class="alphabetical-grouping">
<?php
// Get the current letter from the URL parameter if available, or default to 'A'
$selected_letter = isset($_GET['index']) ? $_GET['index'] : 'A'; // Default to "A" if not set
// Set up query arguments
$args = array(
'post_type' => 'diseases_conditions',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1, // Show all posts
'paged' => get_query_var('paged') ? get_query_var('paged') : 1, // Handle pagination
);
// Modify the query to filter by the first letter if a letter is selected
if ($selected_letter === '#') {
// If the selected filter is '#', show posts starting with a number or special characters
add_filter('posts_where', function ($where, $wp_query) {
global $wpdb;
return $where . " AND " . $wpdb->posts . ".post_title REGEXP '^[0-9\W]'";
}, 10, 2);
} elseif (!empty($selected_letter)) {
// Otherwise, filter by the selected letter (A-Z)
add_filter('posts_where', function ($where, $wp_query) use ($selected_letter) {
global $wpdb;
return $where . " AND " . $wpdb->posts . ".post_title LIKE '" . esc_sql($selected_letter) . "%'";
}, 10, 2);
}
// Run the custom query
$query = new WP_Query($args);
if ($query->have_posts()) :
$groups = [];
// Group posts by their first and first two characters
while ($query->have_posts()) : $query->the_post();
$title = get_the_title();
$first_letter = strtoupper(substr($title, 0, 1));
$first_two_letters = strtoupper(substr($title, 0, 2));
// Initialize groups if not already done
if (!isset($groups[$first_letter])) {
$groups[$first_letter] = [];
}
if (!isset($groups[$first_letter][$first_two_letters])) {
$groups[$first_letter][$first_two_letters] = [];
}
// Add post to the appropriate sub-group
$groups[$first_letter][$first_two_letters][] = [
'id' => get_the_ID(),
'title' => $title,
'permalink' => get_the_permalink(),
'related_post_id' => get_post_meta(get_the_ID(), 'related_post', true), // Fetch related post meta
];
endwhile;
// Display hierarchical groups
foreach ($groups as $letter => $subgroups) {
echo '<h2>' . $letter . '</h2>'; // Main group header without permalink
echo '<div class="group">'; // Open main group
// Display posts directly under the main letter group
foreach ($subgroups as $subgroup_key => $posts) {
if ($letter === $subgroup_key) {
foreach ($posts as $post) {
$related_post_id = $post['related_post_id'];
?>
<article id="post-<?php echo $post['id']; ?>" <?php post_class(); ?>>
<h3>
<?php if ($related_post_id): ?>
<?php
// Display only title without permalink if related post exists
echo $post['title'];
?>
<?php else: ?>
<a href="<?php echo $post['permalink']; ?>"><?php echo $post['title']; ?></a>
<?php endif; ?>
</h3>
<?php
// Check if related post meta exists
if ($related_post_id) {
$related_post_title = get_the_title($related_post_id);
$related_post_permalink = get_permalink($related_post_id);
?>
<!-- Display 'See' with related post link -->
<p>See <a href="<?php echo $related_post_permalink; ?>"><?php echo $related_post_title; ?></a></p>
<?php
}
?>
</article>
<?php
}
}
}
// Display subgroups like "AB", "AC", etc.
foreach ($subgroups as $subgroup_key => $posts) {
if ($letter !== $subgroup_key) {
echo '<h3>' . $subgroup_key . '</h3>'; // Sub-group header without permalink
echo '<div class="sub-group">'; // Open sub-group
foreach ($posts as $post) {
$related_post_id = $post['related_post_id'];
?>
<article id="post-<?php echo $post['id']; ?>" <?php post_class(); ?>>
<h4>
<?php if ($related_post_id): ?>
<?php
// Display only title without permalink if related post exists
echo $post['title'];
?>
<?php else: ?>
<a href="<?php echo $post['permalink']; ?>"><?php echo $post['title']; ?></a>
<?php endif; ?>
</h4>
<?php
// Check if related post meta exists
if ($related_post_id) {
$related_post_title = get_the_title($related_post_id);
$related_post_permalink = get_permalink($related_post_id);
?>
<!-- Display 'See' with related post link -->
<p>See <a href="<?php echo $related_post_permalink; ?>"><?php echo $related_post_title; ?></a></p>
<?php
}
?>
</article>
<?php
}
echo '</div>'; // Close sub-group
}
}
echo '</div>'; // Close main group
}
// Pagination links
echo paginate_links(array(
'total' => $query->max_num_pages,
));
else :
echo '<p>No Diseases & Conditions found.</p>';
endif;
// Reset post data after custom query
wp_reset_postdata();
?>
</div>
<?php
return ob_get_clean(); // Return the output buffer content
}
add_shortcode('diseases_conditions_list', 'display_diseases_conditions');
// functions.php
function filter_diseases_conditions() {
// Check if the 'letter' parameter is set
if (isset($_POST['letter'])) {
// Sanitize the input to prevent security issues
$letter = sanitize_text_field($_POST['letter']);
// Set up the query arguments to filter posts by title
$args = array(
'post_type' => 'diseases_conditions', // Custom post type
'posts_per_page' => 10, // Limit the number of results
'orderby' => 'title',
'order' => 'ASC',
's' => '', // Empty string to enable title search without the default keyword
'post_status' => 'publish', // Only show published posts
);
// Filter titles starting with the specified letter
add_filter('posts_where', function ($where, $wp_query) use ($letter) {
global $wpdb;
// Modify the WHERE clause to match titles starting with the letter
if ($wp_query->get('s') === '') {
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_title LIKE %s", $letter . '%');
}
return $where;
}, 10, 2);
// Execute the query
$query = new WP_Query($args);
// Check if there are any posts
if ($query->have_posts()) {
echo '<ul>';
while ($query->have_posts()) {
$query->the_post();
// Output the results as list items with links
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
echo '</ul>';
} else {
// If no posts were found, output a message
echo '<p>No results found.</p>';
}
// Reset post data
wp_reset_postdata();
// Remove the filter after the query
remove_filter('posts_where', 'custom_posts_where_filter');
}
// End the function properly
wp_die(); // This is required to terminate and return a proper response to the AJAX call
}
// Hook the function to handle AJAX requests
add_action('wp_ajax_nopriv_filter_diseases_conditions', 'filter_diseases_conditions'); // For unauthenticated users
add_action('wp_ajax_filter_diseases_conditions', 'filter_diseases_conditions'); // For authenticated users
// Define the AJAX callback function
function ajax_search_results() {
// Check if the search term is set
if (isset($_POST['search'])) {
// Sanitize the input
$search = sanitize_text_field($_POST['search']);
// Set up the query arguments
$args = array(
'post_type' => 'diseases_conditions', // Change to your custom post type if needed
'posts_per_page' => 10, // Number of results to display
's' => $search, // Search term
);
// Perform the query
$query = new WP_Query($args);
// Check if there are any posts
if ($query->have_posts()) {
echo '<ul>';
while ($query->have_posts()) {
$query->the_post();
// Output the results as list items with links
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
echo '</ul>';
} else {
// If no posts were found, output a message
echo '<p>No results found.</p>';
}
// Reset post data
wp_reset_postdata();
}
// End the function properly
wp_die(); // This is required to terminate and return a proper response to the AJAX call
}
// Hook the function to handle AJAX requests
add_action('wp_ajax_nopriv_ajax_search', 'ajax_search_results'); // For unauthenticated users
add_action('wp_ajax_ajax_search', 'ajax_search_results'); // For authenticated users
function enqueue_custom_styles() {
// Enqueue the custom CSS file
wp_enqueue_style(
'custom-style', // Handle for the stylesheet
get_template_directory_uri() . '/assets/css/custom.css', // Path to the stylesheet
array(), // Dependencies (leave empty if none)
null, // Version (null to avoid cache issues, or set to a specific version number)
'all' // Media (default is 'all', or specify other media types like 'print', 'screen', etc.)
);
}
add_action('wp_enqueue_scripts', 'enqueue_custom_styles');
function display_alphabet_filter() {
$alphabet = range('A', 'Z');
$alphabet[] = '#'; // For numbers and special characters
$current_letter = isset($_GET['index']) ? $_GET['index'] : 'A'; // Default to "A" if not set
ob_start(); // Start output buffering
echo '<div class="alphabet-buttons">';
foreach ($alphabet as $letter) {
$class = ($letter === $current_letter) ? ' class="active"' : '';
echo '<a href="?index=' . esc_attr($letter) . '"' . $class . '>' . $letter . '</a> ';
}
echo '</div>';
return ob_get_clean(); // Return the output buffer content
}
add_shortcode('alphabet_filter', 'display_alphabet_filter');
Be advised that when you update the Pro theme to version 6.5.7, (because right now you are using Pro 6.4.8), all of the custom PHP code will get overwritten with the update. We would recommend that you use the Pro Child theme and place your custom PHP code in the child theme’s functions.php file.
With regards to your Centering issue, I would recommend that you insert a new Section, Row and Column elements without adding post_row
class in the Row element and use the Direction option in the Row element because this is what started the issue.
Please address the above issues because sooner or later, it will get more complicated when using the current set up.
Hope this helps.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.