Posts

Showing posts with the label Wordpress

How to Add View More / View Less Button in Elementor Text Editor

 https://allaboutbasic.com/2026/01/04/elementor-view-more-view-less-button/

Replace permalink with 'your_acf_field_name' your ACF

Image
  function my_custom_permalink_filter( $post_link, $post ) { if ( 'news-articals' === $post->post_type ) { // Target your specific post type name here $acf_field_value = get_field( 'url', $post->ID ); // Replace 'your_acf_field_name' with your ACF field name if ( $acf_field_value ) { $post_link = $acf_field_value; // Replace the tag with the sanitized ACF value } } return $post_link; } add_filter( 'post_type_link', 'my_custom_permalink_filter', 10, 2 );

Custom Functions Wordpress.

 <?php  /* Service Post Start */ function register_services_post_type() {     $labels = array(         'name'               => _x('Services', 'post type general name'),         'singular_name'      => _x('Service', 'post type singular name'),         'menu_name'          => _x('Services', 'admin menu'),         'name_admin_bar'     => _x('Service', 'add new on admin bar'),         'add_new'            => _x('Add New', 'service'),         'add_new_item'       => __('Add New Service'),         'new_item'           => __('New Service'),         'edit_item'          => __('Edit Service'), ...

To extract the month and year from your ACF date field (like 11 August 1989), you can do this:

To extract the month and year from your ACF date field (like 11 August 1989), you can do this: ================ To concatenate the month and year with a space (e.g., August 1989 ), just update your code like this:  <?php  $value = get_field("date"); // Example: "11 August 1989" if ( $value ) { $day        = date('j', strtotime($value));       // Day (1–31) $month      = date('F', strtotime($value));       // Full month name $year       = date('Y', strtotime($value));       // 4-digit year $month_year = $month . ' ' . $year;               // Concatenated month and year ?> <p class="date"><?php echo $day; ?></p> <p class="month-year"><?php echo $month_year; ?></p> <?php } ?>

Elementor displays the same shortcode twice (only on editor) Functions.php Two TIme Costom Post

Elementor displays the same shortcode twice. One in the place where the shortcode is placed, and the other right behind the header. The problem only occurs in the editor. On the page, it displays normally. Please help. How can i fix it? I solved the problem :) I used ob_start(); and return ob_get_clean(); function elementor_shorcode_test ( ) { ob_start (); elementor_shorcode_test_output (); return ob_get_clean (); } Example Code: /*Custom Post type start*/ function cw_post_type_events() { $supports = array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', 'revisions', 'post-formats', ); $labels = array( 'name' => _x('Events', 'plural'), 'singular_name' => _x('Event Post', 'singular'), 'menu_name' => _x('Event Post', 'admin menu'), 'name_admin_bar' => _x('event', ...