Showing posts in calendar view based on start of the day
add_shortcode('ts_day_week_start', function($atts){
$atts = shortcode_atts( array(
'day' => 'Monday',
), $atts);
$res = strtotime('last ' . $atts['day']);
if(date('l') == $atts['day']){
$res = strtotime('this ' . $atts['day']);
}
return $res;
});
add_shortcode('ts_day_week_end', function($atts){
$atts = shortcode_atts( array(
'day' => 'Monday',
), $atts);
$res = strtotime('last ' . $atts['day']);
if(date('l') == $atts['day']){
$res = strtotime('this ' . $atts['day']);
}
$res = strtotime("tomorrow", $res) - 1;
return $res;
});
[wpv-view name="schedule-view" cached="off" tsstart="[ts_day_week_start day='Friday']" tsend="[ts_day_week_end day='Friday']"]
Visto en Toolset
Toolset: Update Title and Slug of Post with Custom Field Content when post saves in the WordPress backend
add_filter( 'wp_insert_post_data' , 'set_issue_title' , '10', 3 );
function set_issue_title( $data , $postarr ) {
if ( 'my_post_type' != $data['post_type'] )
return $data;
$post_title = $data['post_title'];
if ( ! $post_title ) {
$issue_number = trim( $_POST['wpcf']['single1'] );
$issue_type = trim( $_POST['wpcf']['single2']);
$issue_title = $issue_type . ' - ' . $issue_number;
$post_slug = sanitize_title_with_dashes ($issue_title,'','save');
$post_slugsan = sanitize_title($post_slug);
$data['post_title'] = $issue_title;
$data['post_name'] = $post_slugsan;
}
return $data;
}
Visto en https://toolset.com/forums/topic/use-custom-field-to-set-title-slug/
Revisar este otro post: https://toolset.com/forums/topic/use-custom-fields-to-set-post-title-and-post-slug/
Toolset: Auto Generate Post Title and Name/Slug by Combining Other Fields
add_action('cred_save_data', 'build_post_title', 10, 2);
function build_post_title($post_id, $form_data) {
if ($form_data['id']==9999) {
$field1 = get_post_meta($post_id, 'wpcf-street_address', true);
$field2 = get_post_meta($post_id, 'wpcf-city_address', true);
$term_list = wp_get_post_terms($post_id, 'state-address', array("fields" => "names"));
$terms = join("-",$term_list);
$field4 = get_post_meta($post_id, 'wpcf-zip_address', true);
$post_title=$field1.'-'.$field2.'-'.$terms.'-'.$field4;
$slug = sanitize_title($post_title);
wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title,'post_name' => $slug));
}
}
Visto en https://toolset.com/forums/topic/auto-generate-post-title-and-nameslug-by-combining-other-fields/
Toolset: Author frontend filtering with views and ajax
add_shortcode("list-of-authors", "list_of_authors");
function list_of_authors() {
$out = '<option value="">All</option>';
$users = get_users();
foreach ($users as $user) {
$selection = (isset($_GET['author-filter']) ? $_GET['author-filter']: '');
$out .= '<option ' . selected($user->ID, $selection, false) . ' value="' . $user->ID . '">' . $user->display_name . '</a>';
}
return $out;
<select name="author-filter" class="js-wpv-filter-trigger">[list-of-authors]</select>
Visto en: https://toolset.com/forums/topic/author-frontend-filtering-with-views-and-ajax/
Toolset:. Populate custom field with post title
function tssupp_set_pp_title ( $post_id, $post, $update ) {
$field_slug = 'practice-point-title';
$post_type_slug = 'practice-point';
// - bail on wrong post type or on pre-publish auto draft title
$post_type = get_post_type( $post_id );
$post_title = get_the_title( $post_id );
if ( ( $post_type !== $post_type_slug ) || ( $post_title == 'Auto Draft') ) {
return;
}
update_post_meta( $post_id, 'wpcf-' . $field_slug, get_the_title( $post_id ) );
}
add_action( 'save_post', 'tssupp_set_pp_title', 100, 3);
Visto en https://toolset.com/forums/topic/populate-custom-field-with-post-title/
Adsense: Modificar el código de anuncio adaptable
<style>
.example_responsive_1 { width: 320px; height: 100px; }
@media(min-width: 500px) { .example_responsive_1 { width: 468px; height: 60px; } }
@media(min-width: 800px) { .example_responsive_1 { width: 728px; height: 90px; } }
</style>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXX11XXX9" crossorigin="anonymous"></script>
<!-- example_responsive_1 -->
<ins class="adsbygoogle example_responsive_1"
style="display:inline-block"
data-ad-client="ca-pub-XXXXXXX11XXX9"
data-ad-slot="8XXXXX1"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Para adaptar este código de muestra a su propio sitio web, siga estos pasos:
- Cree un bloque de anuncios de display en su cuenta de AdSense y asegúrese de dejar la opción Adaptable seleccionada en la sección «Tamaño del anuncio». Luego, anote la información del código de anuncio adaptable que le indicamos a continuación:
- Su ID de editor (por ejemplo, ca-pub-1234567891234567)
- El ID del bloque de anuncios (es decir,
data-ad-slot
); por ejemplo, 1234567890
- En el código de ejemplo:
- Sustituya todas las instancias de
example_responsive_1
por un nombre único (por ejemplo, página_principal o página_información_123).Notas:- Su nombre único debe contener solo letras del alfabeto inglés (A-Z), números y guiones bajos. Además, el primer carácter debe ser una letra del alfabeto inglés.
- Debe utilizar un nombre único diferente cada vez que adapte este código de ejemplo.
- Sustituya
ca-pub-XXXXXXX11XXX9
por su propio ID de editor. - Sustituya
8XXXXX1
por el ID del bloque de anuncios.
- Sustituya todas las instancias de
- Decida el tamaño que quiere que ocupe el bloque de anuncios en cada anchura de pantalla:
- Si le parecen bien los tamaños de los bloques de anuncios del código de ejemplo, no tendrá que cambiar nada más.
- Si quiere definir tamaños de bloque de anuncios distintos para cada anchura de pantalla, realice estas modificaciones en el código de ejemplo:
- Sustituya
320px
y100px
por la anchura y la altura del bloque de anuncios que quiera usar con anchuras de pantalla de hasta 500 píxeles. - Sustituya
468px
y60px
por la anchura y la altura del bloque de anuncios que quiera usar con anchuras de pantalla desde 500 píxeles hasta 799 píxeles. - Sustituya
728px
y90px
por la anchura y la altura del bloque de anuncios que quiera usar con anchuras de pantalla de 800 píxeles o mayores.
- Sustituya
- Copie y pegue el código de anuncio modificado en el código fuente HTML de la página en la que quiere que aparezcan los anuncios. Nota: Una vez que haya insertado el código de anuncio, le recomendamos que pruebe los anuncios en distintos dispositivos y pantallas para comprobar que se adaptan correctamente a todos ellos.
Visto en https://support.google.com/adsense/answer/9183363?hl=es
WordPress: Agregar efecto de mouseover al bloque Gutenberg en WordPress
.shadow-with-mouse-over-effect {
background: #efefef;
box-shadow: 0 0 17px 0 rgba(0,0,0,0.06);
margin-bottom: 30px;
transition: .3s;
}
.shadow-with-mouse-over-effect:hover {
box-shadow: 0 20px 25px rgba(0,0,0,0.15);
transform: translateY(-4px);
}
Visto en https://myknowledgeportal.com/2019/01/09/add-mouseover-effect-to-gutenberg-block-in-wordpress/
Toolset: Create link to google maps from address field
<a href="https://www.google.com/maps/place/[types field='direccion_comercio' output='raw'][/types]/" title="IR AL COMERCIO">IR AL COMERCIO</a>
Visto en https://toolset.com/forums/topic/button-go-there-google-maps-address/
Toolset: eliminar los parágrafos manuales de la plantilla de contenido
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
$content = force_balance_tags($content);
return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
}