Forum Replies Created

Viewing 15 replies - 1 through 15 (of 15 total)
  • Hi !

    I have the same issue, thanks for the quick fix.

    Johann

    If you want to use the post ID in the Metabox declarations in Meta Box 4.8 here is a full code example :

    // Meta Box
    add_filter( 'rwmb_meta_boxes', 'cc_register_meta_boxes' );
    function cc_register_meta_boxes( $meta_boxes )
    {
    	$prefix = 'cc_';
    
    	global $post;
    	// Admin
    	if (isset($_GET['post']) && !empty($_GET['post'])) {
    	 $post_id = $_GET['post'];
    	}
    	// Front
    	elseif (isset($post) && !empty($post)) {
    	 $post_id = $post->ID;
    	}
    	// Why not
    	else {
    	 $post_id = 0;
    	}
    
    	// Metabox for page id 22
    	if ($post_id == 22) {
    		$meta_boxes[] = array(
    			'id'         => 'Description-blog',
    			'title'      => __( 'En Détail', 'meta-box' ),
    			'post_types' => array( 'post' ),
    			'autosave'   => true,
    			'fields'     => array(
    
    				// Sous titre
    				array(
    					'name'  => __( 'Sous titre', 'meta-box' ),
    					'id'    => "{$prefix}text-blog",
    					'type'    => 'text',
    					'clone' => false,
    				),
    
    				// URL
    				array(
    					'name'  => __( 'Lien vers site web', 'meta-box' ),
    					'id'    => "{$prefix}url-blog",
    					'type'    => 'text',
    					'clone' => false,
    				),
    			)
    		);
    	}
    }

    @tran Ngoc Tuan Anh : Thanks for your support. I used WP_Debug to find that the $post_id variable was causing the trouble. Not sure why in 4.8 and not in 4.7.3 but anyway it was my mistake.

    If you need post_id in the register_meta_boxes function use this :

    global $post;
    
    // Admin
    if (isset($_GET['post']) && !empty($_GET['post'])) {
    	$post_id = $_GET['post'];
    }
    // Front
    elseif (isset($post) && !empty($post)) {
    	$post_id = $post->ID;
    }
    // Why not
    else {
    	$post_id = 0;
    }

    Working fine now !

    Thanks again, Johann

    I have another example (sorry to spam but I’m trying to give as much informations as possible) :

    On a contact page :

    <article class="col-md-8">
    					<?php the_content(); ?>
    					<div class="contact-infos">
    						<?php echo rwmb_meta('cc_textarea-infos-contact'); ?>
    					</div>
    					<div class="contact-reseaux">
    						<?php echo rwmb_meta('cc_textarea-reseaux-contact'); ?>
    					</div>
    				</article>

    Nothing is echoed in 4.8, works well in 4.7.3. Both are wysiwyg fields.

    It seems to me that rwmb_meta can’t get (or use) the id of a regular wordpress page.

    $post_id = get_the_ID();
        // variables
        $titreservices = rwmb_meta('cc_text-section-services', $post_id);

    This code doesn’t work in 4.8, $post_id is 22 (page id) and the page has a meta cc_text-section-services (cas access it in the admin and in the front via get_post_meta)

    I’m sorry to reinterrup this conversation but the problem does not come from a wrong get_the_ID().

    I did it before the to places where I use rwmb_meta and the first one get 22 (the page id) and the second one 327 (the post id in the second loop). rwmb_meta works in the second loop but not in the page loop.

    Any other idea ?
    I can send you full code if you want.

    It was working fine with 4.7.3 but I guess you are right it makes sense.
    I’m going to try I keep you informed !

    Jo

    Thanks for the vid I liked it 🙂

    So my wordpress is lastest version and the only plugin activated is Meta Box.
    I don’t think the environment is relevant but I noticed something.

    On the front-page.php template some of the metaboxes work, some don’t.

    At the begining of the file I do that :

    <?php get_header(); ?>
    
    <?php  while ( have_posts() ) : the_post();  ?>
        <?php
        // variables
        $titreservices = rwmb_meta('cc_text-section-services');
        $textlien = rwmb_meta('cc_text-lien-savoirplus');
        $titremembres = rwmb_meta('cc_text-section-membres');
        $textmembres = rwmb_meta('cc_textarea-text-carte');
        $textboutoncarte = rwmb_meta('cc_text-bouton-carte');
        ?>

    Thoses meta boxes are empty.

    Later, I use a WP_Query to get some content and in this second loop I have some meta boxes :

    if ($query_slider->have_posts()) {
    				?>
    					<?php
    					while ( $query_slider->have_posts() ) : $query_slider->the_post();
                        $post_type = $post->post_type;
    					?>
    					<div class="slide" style="background: url(<?php $url = wp_get_attachment_image_src( get_post_thumbnail_id($id), 'large' ); echo $url['0']; ?>) no-repeat center center; background-size: cover;">
    						<div class="contenuslider">
    							<h3 class="title"><?php the_title(); ?></h3>
    							<p class="soustitre"><?php $textsoustitre = rwmb_meta( 'cc_text-soustitre' ); if (!empty($textsoustitre)) { echo $textsoustitre; } ?></p>
    							<p class="text"><?php if($post_type == "post") {$textslide = strip_tags(get_the_excerpt());} else {$textslide = rwmb_meta( 'cc_text-slider' );} if (!empty($textslide)) { echo $textslide; } ?></p>
    							<a href="<?php if($post_type == "post") {$url = the_permalink();} else {$url = rwmb_meta( 'cc_url-slider' );} if (!empty($url)) { echo $url; } ?>" class="urlslide"><?php if (!empty($textlien)) { echo $textlien; } else { echo "-"; } ?></a>
    						</div>
    					</div>
    					<?php
    					wp_reset_postdata();
    					endwhile; // end of the loop.
    					?>
    				<?php } ?>

    And for this it works !

    Here you go !

    // Configurations des métaboxes
    add_filter( 'rwmb_meta_boxes', 'cc_register_meta_boxes' );
    function cc_register_meta_boxes( $meta_boxes )
    {
    	$prefix = 'cc_';
    	$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
    
    	$meta_boxes[] = array(
    		'id'         => 'detail-slider',
    		'title'      => __( 'En détail', 'meta-box' ),
    		'post_types' => array( 'slider' ),
    		'context'    => 'normal',
    		'priority'   => 'high',
    		'autosave'   => true,
    		'fields'     => array(
    
    			// HYPERLIEN
    			array(
    				'name'  => __( 'Hyperlien', 'meta-box' ),
    				'id'    => "{$prefix}url-slider",
    				'desc'  => __( 'URL de la slide', 'meta-box' ),
    				'type'  => 'text',
    				'clone' => false,
    			),
    			// SOUS TITRE
    			array(
    				'name'  => __( 'Sous Titre', 'meta-box' ),
    				'id'    => "{$prefix}text-soustitre",
    				'desc'  => __( 'Informations complémentaires', 'meta-box' ),
    				'type'  => 'text',
    				'clone' => false,
    			),
    			// TEXTE
    			array(
    				'name'  => __( 'Description', 'meta-box' ),
    				'id'    => "{$prefix}text-slider",
    				'desc'  => __( 'Une courte description associée à la slide', 'meta-box' ),
    				'type'  => 'text',
    				'clone' => false,
    			),
    		)
    	);
    
    	$meta_boxes[] = array(
    		'id'         => 'detail-lieu',
    		'title'      => __( 'A propos de votre lieu', 'meta-box' ),
    		'post_types' => array( 'membres' ),
    		'context'    => 'normal',
    		'priority'   => 'high',
    		'autosave'   => true,
    		'fields'     => array(
    
    			// VILLE
    			array(
    				'name'    => __( 'Ville', 'meta-box' ),
    				'id'      => "{$prefix}text-ville-lieu",
    				'desc'    => "Utilisé pour faire la liste des villes en page d'accueil. Les lieux situés dans la même ville sont regroupés.",
    				'type'    => 'text',
    			),
    			// Adresse
    			array(
    				'name' => __( 'Adresse complète', 'meta-box' ),
    				'desc' => 'Affichée sur votre profil et dans votre fiche détaillée sur la carte en page d\'accueil. N\'oubliez pas de positionner correctement le pointeur dans la minicarte pour y figurer.',
    				'id'   => "{$prefix}textarea-adresse",
    				'type' => 'textarea',
    				'cols' => 20,
    				'rows' => 3,
    			),
    			// DATE
    			array(
    				'name'       => __( 'Date de création', 'meta-box' ),
    				'id'         => "{$prefix}date-creation",
    				'type'       => 'date',
    				// jQuery date picker options. See here http://api.jqueryui.com/datepicker
    				'js_options' => array(
    					'appendText'      => __( '(dd-mm-yyyy)', 'meta-box' ),
    					'dateFormat'      => __( 'd MM yy', 'meta-box' ),
    					'changeMonth'     => true,
    					'changeYear'      => true,
    					'showButtonPanel' => true,
    				),
    			),
    			// NOMBRE EVTS
    			array(
    				'name' => __( 'Nombre d\'événements et de rencontres en 2015', 'meta-box' ),
    				'id'   => "{$prefix}nombre-evenements",
    				'type' => 'number',
    				'min'  => 0,
    				'step' => 1,
    			),
    			// NOMBRE PARTICIPANTS
    			array(
    				'name' => __( 'Nombre de participants à vos événements et rencontres en 2015', 'meta-box' ),
    				'id'   => "{$prefix}nombre-participants",
    				'type' => 'number',
    				'min'  => 0,
    				'step' => 1,
    			),
    			// NOMBRE COWORKERS
    			array(
    				'name' => __( 'Nombre de coworkers par jour (en moyenne)', 'meta-box' ),
    				'id'   => "{$prefix}nombre-coworkers",
    				'type' => 'number',
    				'min'  => 0,
    				'step' => 1,
    			),
    			array(
    				'name'             => __( 'Quelques photos de votre lieu', 'meta-box' ),
    				'id'               => "{$prefix}image-photolieu",
    				'type'             => 'image_advanced',
    				'max_file_uploads' => 10,
    			),
    		)
    	);
    
    	$meta_boxes[] = array(
    		'id'         => 'detail-structure',
    		'title'      => __( 'A propos de votre structure', 'meta-box' ),
    		'post_types' => array( 'membres' ),
    		'context'    => 'normal',
    		'priority'   => 'high',
    		'autosave'   => true,
    		'fields'     => array(
    
    			// NOM STRUCTURE
    			array(
    				'name'  => __( 'Nom de la structure porteuse', 'meta-box' ),
    				'id'    => "{$prefix}text-nom",
    				'type'  => 'text',
    			),
    			// FORME JURIDIQUE
    			array(
    				'name'    => __( 'Forme juridique de la structure porteuse :', 'meta-box' ),
    				'id'      => "{$prefix}radio-juridique",
    				'type'    => 'radio',
    				// Array of 'value' => 'Label' pairs for radio options.
    				// Note: the 'value' is stored in meta field, not the 'Label'
    				'options' => array(
    					'association' => __( 'Association', 'meta-box' ),
    					'sa' => __( 'SA', 'meta-box' ),
    					'sarl' => __( 'SARL', 'meta-box' ),
    					'eurl' => __( 'EURL', 'meta-box' ),
    					'scop' => __( 'SCOP', 'meta-box' ),
    					'entite-publique' => __( 'Entité Publique', 'meta-box' ),
    					'autre' => __( 'Autre', 'meta-box' ),
    
    				),
    			),
    			// SINON AUTRE
    			array(
    				'name'  => __( 'Si autre forme juridique précisez', 'meta-box' ),
    				'id'    => "{$prefix}text-juridique-autre",
    				'type'  => 'text',
    			),
    			// PRESENTATION STRUCTURE
    			array(
    				'name' => __( 'Présentation en quelques mots de la structure porteuse', 'meta-box' ),
    				'id'   => "{$prefix}textarea-presentation",
    				'type' => 'textarea',
    				'cols' => 20,
    				'rows' => 3,
    			),
    			// NOMBRE SALARIES
    			array(
    				'name' => __( 'Nombre de salariés', 'meta-box' ),
    				'id'   => "{$prefix}nombre-salaries",
    				'type' => 'number',
    				'min'  => 0,
    				'step' => 1,
    			),
    			// BUDGET 2015
    			array(
    				'name' => __( 'Budget annuel 2015', 'meta-box' ),
    				'desc' => 'En €',
    				'id'   => "{$prefix}nombre-budget",
    				'type' => 'number',
    				'min'  => 0,
    				'step' => 1,
    			),
    			// PART FINANCEMENT PUBLIC
    			array(
    				'name' => __( 'Part de financement public dans votre budget', 'meta-box' ),
    				'desc' => '(en %)',
    				'id'   => "{$prefix}nombre-partpublic",
    				'type' => 'number',
    				'min'  => 0,
    				'step' => 1,
    				'max'  => 100,
    			),
    		)
    	);
    
    	$meta_boxes[] = array(
    		'id'         => 'detail-reseau',
    		'title'      => __( 'Votre lieu et le Réseau', 'meta-box' ),
    		'post_types' => array( 'membres' ),
    		'context'    => 'normal',
    		'priority'   => 'high',
    		'autosave'   => true,
    		'fields'     => array(
    
    			// POURQUOI MEMBRE TECHPLACES
    			array(
    				'name' => __( 'Pourquoi avoir choisi de devenir membre de Tech Places ?', 'meta-box' ),
    				'id'   => "{$prefix}textarea-pourquoi-membre",
    				'type' => 'textarea',
    				'cols' => 20,
    				'rows' => 3,
    			),
    			// TAGS VALEUR AJOUTEE
    			array(
    				'name' => __( 'Quels sont les 3 tags de votre lieu décrivant au mieux votre valeur ajoutée au sein du réseau', 'meta-box' ),
    				'id'   => "{$prefix}textarea-tags-valeur-ajoutee",
    				'desc' => "Exemples : #projetseuropéens, #accélérateur, #consoco #BigData #startup #grandscomptes #labodesusages #hackathon...",
    				'type' => 'textarea',
    				'cols' => 20,
    				'rows' => 3,
    			),
    		)
    	);
    
    	$meta_boxes[] = array(
    		'id'         => 'detail-evt',
    		'title'      => __( 'Votre évènement majeur', 'meta-box' ),
    		'post_types' => array( 'membres' ),
    		'context'    => 'normal',
    		'priority'   => 'high',
    		'autosave'   => true,
    		'fields'     => array(
    
    			array(
    				'name' => __( 'Titre de l\'évènement', 'meta-box' ),
    				'id'   => "{$prefix}text-evenement",
    				'type' => 'text',
    			),
    			// PRESENTATION EVT ANNUEL
    			array(
    				'name' => __( 'Présentez en quelques mots votre événement phare annuel', 'meta-box' ),
    				'id'   => "{$prefix}textarea-presentation-evenement",
    				'type'    => 'wysiwyg',
    				'options' => array(
    					'textarea_rows' => 4,
    					'teeny'         => true,
    					'media_buttons' => false,
    				),
    			),
    		)
    	);
    
    	$meta_boxes[] = array(
    		'id'         => 'detail-web',
    		'title'      => __( 'Votre lieu sur le Web', 'meta-box' ),
    		'post_types' => array( 'membres' ),
    		'context'    => 'normal',
    		'priority'   => 'high',
    		'autosave'   => true,
    		'fields'     => array(
    
    			// COMPTE TWITTER
    			array(
    				'name' => __( 'Compte Twitter', 'meta-box' ),
    				'id'   => "{$prefix}url-twitter",
    				'type' => 'url',
    			),
    			// PAGE FACEBOOK
    			array(
    				'name' => __( 'Page Facebook', 'meta-box' ),
    				'id'   => "{$prefix}url-facebook",
    				'type' => 'url',
    			),
    			// SITE WEB
    			array(
    				'name' => __( 'Site web', 'meta-box' ),
    				'id'   => "{$prefix}url-web",
    				'type' => 'url',
    			),
    		)
    	);
    
    	$meta_boxes[] = array(
    		'id'         => 'detail-service',
    		'title'      => __( 'Détails', 'meta-box' ),
    		'post_types' => array( 'services' ),
    		'context'    => 'normal',
    		'priority'   => 'high',
    		'autosave'   => true,
    		'fields'     => array(
    
    			// Logo image service
    			array(
    				'name'    => __( 'Logo du service', 'meta-box' ),
    				'id'      => "{$prefix}image-logo-service",
    				'type'    => 'image_advanced',
    				'max_file_uploads' => 1,
    			),
    		)
    	);
    
    	$meta_boxes[] = array(
    		'id'         => 'detail-niveaux',
    		'title'      => __( 'Niveau d\'accompagnement', 'meta-box' ),
    		'post_types' => array( 'services' ),
    		'context'    => 'normal',
    		'priority'   => 'high',
    		'autosave'   => true,
    		'fields'     => array(
    
    			// NIVEAU 1
    			array(
    				'name'    => __( 'Niveau 1', 'meta-box' ),
    				'id'      => "{$prefix}wysiwyg-niveau-accompagnement1",
    				'type'    => 'wysiwyg',
    				'options' => array(
    					'textarea_rows' => 4,
    					'teeny'         => false,
    					'media_buttons' => false,
    					'textarea_rows' => 15,
    				),
    			),
    			// NIVEAU 2
    			array(
    				'name'    => __( 'Niveau 2', 'meta-box' ),
    				'id'      => "{$prefix}wysiwyg-niveau-accompagnement2",
    				'type'    => 'wysiwyg',
    				'desc'    => 'Optionnel',
    				'options' => array(
    					'textarea_rows' => 4,
    					'teeny'         => false,
    					'media_buttons' => false,
    					'textarea_rows' => 15,
    				),
    			),
    			// NIVEAU 3
    			array(
    				'name'    => __( 'Niveau 3', 'meta-box' ),
    				'id'      => "{$prefix}wysiwyg-niveau-accompagnement3",
    				'type'    => 'wysiwyg',
    				'desc'    => 'Optionnel',
    				'options' => array(
    					'textarea_rows' => 4,
    					'teeny'         => false,
    					'media_buttons' => false,
    					'textarea_rows' => 15,
    				),
    			),
    			// NIVEAU 4
    			array(
    				'name'    => __( 'Niveau 4', 'meta-box' ),
    				'id'      => "{$prefix}wysiwyg-niveau-accompagnement4",
    				'type'    => 'wysiwyg',
    				'desc'    => 'Optionnel',
    				'options' => array(
    					'textarea_rows' => 4,
    					'teeny'         => false,
    					'media_buttons' => false,
    					'textarea_rows' => 15,
    				),
    			),
    		)
    	);
    
    	// HP
    	if ( '22' == $post_id ) {
    		$meta_boxes[] = array(
    			'id'         => 'detail',
    			'title'      => __( 'En détail', 'meta-box' ),
    			'post_types' => array( 'page' ),
    			'context'    => 'normal',
    			'priority'   => 'high',
    			'autosave'   => true,
    			'fields'     => array(
    
    				// Nom Services
    				array(
    					'name' => __( 'Nom de la section Services', 'meta-box' ),
    					'id'   => "{$prefix}text-section-services",
    					'desc' => "Le texte des services est Ă  modifier dans l'extrait de chaque service.",
    					'type' => 'text',
    				),
    				// Text lien en savoir plus
    				array(
    					'name' => __( 'Texte lien', 'meta-box' ),
    					'desc' => 'Texte du lien en bas à droite du service pour le voir en détail.',
    					'id'   => "{$prefix}text-lien-savoirplus",
    					'type' => 'text',
    				),
    				// Titre Membres
    				array(
    					'name' => __( 'Nom de la section Membres', 'meta-box' ),
    					'id'   => "{$prefix}text-section-membres",
    					'desc' => "Le texte des services est Ă  modifier dans l'extrait de chaque service.",
    					'type' => 'text',
    				),
    				// Titre Membres
    				array(
    					'name' => __( 'Texte bouton membres', 'meta-box' ),
    					'id'   => "{$prefix}text-bouton-carte",
    					'desc' => "Bouton qui mène à la page membres en dessous la carte",
    					'type' => 'text',
    				),
    				// Texte Membres
    				array(
    					'name' => __( 'Texte d\'introduction Ă  la carte', 'meta-box' ),
    					'id'   => "{$prefix}textarea-text-carte",
    					'type' => 'textarea',
    					'cols' => 20,
    					'rows' => 3,
    				),
    			)
    		);
    	}
    
    	// Page Réseau
    	if ( '24' == $post_id ) {
    		$meta_boxes[] = array(
    			'id'         => 'detail',
    			'title'      => __( 'En détail', 'meta-box' ),
    			'post_types' => array( 'page' ),
    			'context'    => 'normal',
    			'priority'   => 'high',
    			'autosave'   => true,
    			'fields'     => array(
    
    				// Introduction
    				array(
    					'name' => __( 'Introduction', 'meta-box' ),
    					'id'   => "{$prefix}textarea-introduction",
    					'desc' => "S'affiche sur fond orange.",
    					'type' => 'wysiwyg',
    					'options' => array(
    						'textarea_rows' => 4,
    						'teeny'         => true,
    						'media_buttons' => false,
    					),
    				),
    			)
    		);
    	}
    
    return $meta_boxes;
    }

    Hi !

    The code to register :

    add_filter( 'rwmb_meta_boxes', 'cc_register_meta_boxes' );
    function cc_register_meta_boxes( $meta_boxes ) {

    The code to get stuff :
    $textslide = rwmb_meta( 'cc_text-slider' ); echo $textslide;

    Nothing in there.
    Get post meta works though !

    Any ideas ?

    Thanks,
    Jo

    Hi !

    Same problem here, followed everything :
    4.8.1
    filter

    The function rwmb_meta() does nothing. Meta information is in the database though.
    Went back to 4.7.3.

    Ask me if you want any information.

    Thanks
    Johann

    Hi !

    I’m having the same issue, any news on this ?

    Thanks,

    Johann

    PS :
    Plugins installed on my website :

    Akismet
    Version 3.1.1

    Attachment Pages Redirect
    Version 1.0

    Contact Form 7
    Version 4.1.2

    Custom Content Width
    Version 1.0.1

    Custom Facebook Feed
    Version 2.3.4

    Escape NextGen Gallery
    Version 1.0

    File Un-Attach
    Version 1.1

    HeadSpace2
    Version 3.6.41

    Hello Dolly
    Version 1.6

    IK Facebook Plugin
    Version 2.12.5

    Jetpack par WordPress.com
    Version 3.5.3

    Lightbox Plus Colorbox
    Version 2.7.2

    MailPoet Newsletters
    Version 2.6.15

    NextGEN Gallery by Photocrati
    Version 2.1.0

    NextGEN Scroll Gallery
    Version 1.8.2

    Regenerate Thumbnails
    Version 2.2.4

    Slimbox
    Version 1.0.7

    WC PayPal Pro Hosted Solution
    Version 1.1.1

    WooCommerce
    Version 2.3.9

    WooCommerce Menu Cart
    Version 2.5.7

    WooCommerce Sequential Order Numbers
    Version 1.4.0

    WordPress Page Widgets
    Version 2.6

    WP Statistics
    Version 9.3.1

    Hi !

    I’m facing the same issue ! Let me know if I can help with information to solve the problem.

    Have a nice day,
    Johann

    Thread Starter JLesacher

    (@jlesacher)

    Hi !

    Thanks for the reply !
    It was working before I don’t know why it’s not anymore.
    Anyway have a nice day

    Johann

    Thread Starter JLesacher

    (@jlesacher)

    Hi !

    I found a solution in another related thread.
    Thanks to Piotr Bieszk :

    In version 4.8 replace existing line 717 of simple-share-adder.php

    $urlCurrentPage = (isset($atts[‘url’]) ? $atts[‘url’] : ssba_current_url());

    with

    if (get_permalink($post->ID) != “”) {
    $urlCurrentPage = get_permalink($post->ID);
    } else {
    $urlCurrentPage = (isset($atts[‘url’]) ? $atts[‘url’] : ssba_current_url());
    }

    => Worked for me

    Bisous,
    Johann

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