Exactly where I have to insert get_next_post_link() in a post?

When you develop a theme you can add specific styling per each post type. by default they all use the single.php theme file, but single-{post-type}.php will be used for the specific post type being displayed (for the full template hierarchy – https://developer.wordpress.org/themes/basics/template-hierarchy/#the-template-file-hierarchy) The navigation links like the prev and next ones you are trying to … Read more

What is the best security $_POST method?

You have to sanitize or escape the data based on type and application of the data. Like below- $title = sanitize_text_field( $_POST[‘title’] ); update_post_meta( $post->ID, ‘title’, $title ); It’s a quite huge topic. You better read this Validating Sanitizing and Escaping User Data.

WordPress format json in postmeta table

Part 1 – To remove the double quotes/extra characters: Instead of trying regular expressions, since the output is somewhat predictable, I would try the following instead of the getCapitalLetters function: function strip_cruft( $str ) { $str = str_replace( ‘”;s’, ”, $str ); $str = str_replace( ‘”‘, ”, $str ); return $str; } Part 2 – … Read more

ACF + WPML: How to translate date fields?

You can use the global $wp_locale to get the month translated in each language. You just need to get the month number (01 to 12) from the Acf field. You have the functions in the WP_Locale class get_month() and get_month_abbrev() global $wp_locale; $month = $wp_locale->get_month(04); // Output april in english $month_abbrev = $wp_locale->get_month_abbrev($month); // Output … Read more

Add CSS class to PHP Statement

You need to wrap it in an HTML element that has a class. Doing it with your code will require changes. You can either do it outside the PHP, which will require changing where you open and close the PHP tags: <?php } else { ?> <span class=”classname”> <?php esc_html_e(‘No results found’,’ThemeName’); ?> </span> <?php … Read more

ACF Load Field Groups Programmatically [closed]

In case anyone needs it, this is working for my needs: add_filter(‘acf/get_field_group’, ‘my_change_field_group’); function my_change_field_group($group) { $get_current_screen = get_current_screen(); $get_current_post_type = $get_current_screen->post_type; $my_option = get_field(‘my-option’,’option’); if ( $get_current_post_type == ‘my-cpt’ && $my_option == ‘stuff’ && $group[‘key’] == ‘group_123456789’ ) { $group[‘location’] = array( array( array( ‘param’ => ‘post_type’, ‘operator’ => ‘==’, ‘value’ => ‘my-cpt’, ), … Read more

Change post status by custom fields

All you need to do is to use save_post hook. Here’s how: function change_post_status_based_on_custom_field( $post_id ) { // If this is just a revision, don’t do anything. if ( wp_is_post_revision( $post_id ) ) return; // Get field value $value = get_post_meta( $post_id, ‘played’, true ); $status = $value ? ‘publish’ : ‘draft’; // If status … Read more