WordPress.org

Forums

Magic Action Box
MAB not appearing in custom post type (14 posts)

  1. sebfrey
    Member
    Posted 1 year ago #

    I am new to Magic Action Box...I have several custom post types, but Magic Action Box does not show up in the editor for these custom posts. What to do?

    https://wordpress.org/plugins/magic-action-box/

  2. Ryann Micua
    Member
    Plugin Author

    Posted 1 year ago #

    In your functions.php file, add the following code:

    add_filter('mab_allowed_post_types', 'add_cpt_to_mab');
    add_cpt_to_mab($posttypes){
       $posttypes[] = 'your-post-type'; // slug of your custom post type
       // $posttypes[] = 'another-post-type'; //uncomment this line if you wish to add another post type
       return $posttypes;
    }
  3. sebfrey
    Member
    Posted 1 year ago #

    Thanks! That did the trick.

  4. ta_jonathan
    Member
    Posted 1 year ago #

    Wouldn't you need to make that a function?
    Is it also possible to add magic action box popups to custom post types?

  5. ManuelMDF
    Member
    Posted 2 months ago #

    I have tried but not found, it return a error:

    Parse error: syntax error, unexpected '{' in /home3/manuel/public_html/CursoWordpress/wp-content/plugins/magic-action-box/lib/functions.php on line 170

  6. Ryann Micua
    Member
    Plugin Author

    Posted 2 months ago #

    you need to add it to your theme's functions.php file. not on the plugin.

    and this is the correct code:

    add_filter('mab_allowed_post_types', 'add_cpt_to_mab');
    function add_cpt_to_mab($posttypes){
       $posttypes[] = 'your-post-type'; // slug of your custom post type
       // $posttypes[] = 'another-post-type'; //uncomment this line if you wish to add another post type
       return $posttypes;
    }
  7. ManuelMDF
    Member
    Posted 2 months ago #

    Thanks!. It's work, appear in the backend, but not in the fronted :-(.

  8. Ryann Micua
    Member
    Plugin Author

    Posted 2 months ago #

    would you happen to know if the custom post type uses the_content() method to show the content? because MAB uses the the_content filter hook to "inject" the action boxes.

  9. ManuelMDF
    Member
    Posted 2 months ago #

    Yes, It uses.

    <?php
    /**
     * @package Alpine
    */
    /*
    Template Name: One Page Template
    */
    
    get_header();
    ?>
        <?php if ( function_exists( 'ot_get_option' ) ):
          if(ot_get_option('menu_position') == 1):?>
          <div class="menu_first">
            <?php get_template_part( 'assets/php/partials/main', 'nav' ); ?>
          </div>
        <?php endif;endif;?>
    
        <?php if ( function_exists( 'ot_get_option' ) ):
          if(ot_get_option('enable_preloader') != 2):?>
          <div class="mask" <?php echo(ot_get_option('loader_bg')!= '') ? 'style="background:'.ot_get_option('loader_bg').'"':'' ?>>
            <div id="intro-loader" <?php echo(ot_get_option('loader_icon')!= '') ? 'style="background:url('.ot_get_option('loader_icon').');"':'' ?>></div>
          </div>
        <?php endif;endif;?>
    
        <section id="home" <?php echo(ot_get_option('menu_position')== 1) ? 'class="menu_top"':'' ?> >
          <?php the_content(); ?>
        </section>
    
        <?php if ( function_exists( 'ot_get_option' ) ):
          if(ot_get_option('menu_position') != 1):?>
          <?php get_template_part( 'assets/php/partials/main', 'nav' ); ?>
        <?php endif; endif;?>
    
    		<?php $the_query_onepage = new WP_Query( 'post_type=onepage&posts_per_page=50');?>
    		<?php if ($the_query_onepage->have_posts() ) : ?>
    			<?php while ($the_query_onepage->have_posts() ) : $the_query_onepage->the_post(); ?>
    				<?php get_template_part('assets/php/partials/content', 'page'); ?>
    			<?php endwhile; wp_reset_query();?>
    		<?php endif; ?> 
    
    <?php get_footer(); ?>

    Thanks.

  10. Ryann Micua
    Member
    Plugin Author

    Posted 2 months ago #

    What is the name of the file you took this code from?

  11. ManuelMDF
    Member
    Posted 2 months ago #

    Sorry for the last, the file names page_onepage.php

  12. ManuelMDF
    Member
    Posted 2 months ago #

    My theme is a OnePage Theme, when it show sections one by one don't appear, but in the onepage (alone) it show.

  13. Ryann Micua
    Member
    Plugin Author

    Posted 2 months ago #

    A bit confused here. That doesn't look like a template for a custom post type. This is the doc for custom post templates http://codex.wordpress.org/Post_Type_Templates

    Filename you described is a page template - for Pages.

    And yes the form should show for single page. Can you show me the page where action boxes don't show?

  14. ManuelMDF
    Member
    Posted 2 months ago #

    OK, don't show, It show

    In the first you must go to "INCRíBETE YA" and go to the prices

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Magic Action Box
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic