Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support longnguyen

    (@longnguyen)

    Hi @zabriskie73

    You can create a secondary title with Meta Box easily. Please follow these steps:

    – Create a field text by follow the documentation or use Online Generator tool to build the field and generate the code quickly.

    – Add the code to the file functions.php in the theme/child theme folder or use Code Snippets.

    – Find the file template of the theme which displays the single post, add the code to show the field text value above the post title.

    All done, edit the post and add the secondary title to show on the single post. See my screen record https://www.loom.com/share/1082d87a8f9248d28ccd20c694d4a7f7.

    Regards.

    Thread Starter zabriskie73

    (@zabriskie73)

    Hi Long,
    Thank you very much for your help.
    However it does not work yet. I have the metabox on my post backend, but i don’t know how to put the line :

    <h2><?php echo rwmb_meta( ‘second_title’ ) ?></h2>

    I tried to put it on oceanwp/partials/single/content.php
    and oceanwp/partials/single/header.php

    but no results.
    I’m obvious done something wrong, but i’m stuck here. Any idea ? ??

    Plugin Support longnguyen

    (@longnguyen)

    Hi @zabriskie73

    Could you please share the code that you’ve used to create the field?

    I think the problem comes from the ID of the field

    'id' => $prefix . 'second_title'

    if you use the tool Online Generator, the $prefix variable has the value prefix- so you have to use the field ID prefix-second_title.

    <h2><?php echo rwmb_meta( 'prefix-second_title' ) ?></h2>

    Thread Starter zabriskie73

    (@zabriskie73)

    Hi,

    I’ve tried to follow the steps of your loom demo.
    Here is the code :

    function your_prefix_get_meta_box( $meta_boxes ) {
    	$prefix = '';
    
    	$meta_boxes[] = array(
    		'id' => 'untitled',
    		'title' => esc_html__( 'Untitled Metabox', 'metabox-online-generator' ),
    		'post_types' => array('post', 'page' ),
    		'context' => 'advanced',
    		'priority' => 'default',
    		'autosave' => 'false',
    		'fields' => array(
    			array(
    				'id' => $prefix . 'second_title',
    				'type' => 'text',
    				'name' => esc_html__( 'Second_title', 'metabox-online-generator' ),
    			),
    		),
    	);
    Plugin Support longnguyen

    (@longnguyen)

    Hi,

    Please see my screen record again https://www.loom.com/share/2ddffc8310724f4a8b29c0c81a8ccab9.

    I’ve installed the theme OceanWP then add the code to show the field value <h2><?php echo rwmb_meta( 'second_title' ) ?></h2> to the file wp-content/themes/oceanwp/partials/single/header.php and it works as well.

    Thread Starter zabriskie73

    (@zabriskie73)

    Hi,
    Thank you again for the demo. It works.
    Unfortunately, it’s not enough. I’m working on Elementor Pro, and the second-title is not recognized as a part of the main title. I’ve had downloaded Metabox Elementor Integrator to add specific metabox field on my template, and then it works.
    But, the main goal of my request is to replace my “Second Title” plug-in.
    Why ?
    Because on my home page (canalanimal.fr), i have several post widgets and all of them display my plug-in second title (in blue above the main title) without problem… except the widgets running with AJAX. When i click on the arrows on AJAX widgets to scroll the posts titles, the second titles are removed after the reload (so, from the page 2).
    But here, the metabox second title does not even appears at all on any posts widgets…

    Anyway, i’m grateful for your help, and myabe i will find another usage for metabox later.

    • This reply was modified 4 years, 5 months ago by zabriskie73.
    • This reply was modified 4 years, 5 months ago by zabriskie73.
    • This reply was modified 4 years, 5 months ago by zabriskie73.
    Plugin Support longnguyen

    (@longnguyen)

    Ok, thank you for spending your time with Meta Box. I’m going to mark this topic as Resolved.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Can i do secondary title with Metabox’ is closed to new replies.