1

A shortcode from a plugin I am trying to use is not working on my static front page, it only shows as plain shortcode text but It works well on all of my other pages.

I'm using Illdy theme, I've already asked about this issue on their forum but I have a feeling that the issue is in my front-page.php file. Is there anything missing or extra in my front-page.php file that is preventing the shortcode from working?

UPDATE: in front-page.php, I changed get_the_content() to the_content() and I fixed my issue. Is this a good fix? Can I feel comfortable in making this change?

Here's my front-page.php:

<?php
/**
 *  The template for displaying the front page.
 *
 *  @package WordPress
 *  @subpackage illdy
 */



get_header();


if( get_option( 'show_on_front' ) == 'posts' ): ?>

    <div class="container">
        <div class="row">
            <div class="col-sm-7">
                <section id="blog">
                    <?php do_action( 'illdy_above_content_after_header' ); ?>
                    <?php
                    if( have_posts() ):
                        while( have_posts() ):
                            the_post();
                            get_template_part( 'template-parts/content', get_post_format() );
                        endwhile;
                    else:
                        get_template_part( 'template-parts/content', 'none' );
                    endif;
                    ?>
                    <?php do_action( 'illdy_after_content_above_footer' ); ?>
                </section><!--/#blog-->
            </div><!--/.col-sm-7-->
            <?php get_sidebar(); ?>
        </div><!--/.row-->
    </div><!--/.container-->

<?php
else:

    $sections_order_first_section = get_theme_mod( 'illdy_general_sections_order_first_section', 1 );
    $sections_order_second_section = get_theme_mod( 'illdy_general_sections_order_second_section', 2 );
    $sections_order_third_section = get_theme_mod( 'illdy_general_sections_order_third_section', 3 );
    $sections_order_fourth_section = get_theme_mod( 'illdy_general_sections_order_fourth_section', 4 );
    $sections_order_fifth_section = get_theme_mod( 'illdy_general_sections_order_fifth_section', 5 );
    $sections_order_sixth_section = get_theme_mod( 'illdy_general_sections_order_sixth_section', 6 );
    $sections_order_seventh_section = get_theme_mod( 'illdy_general_sections_order_seventh_section', 7 );
    $sections_order_eighth_section = get_theme_mod( 'illdy_general_sections_order_eighth_section', 8 );

    if( have_posts() ):
        while( have_posts() ): the_post();
            $static_page_content = get_the_content();
            if ( $static_page_content != '' ) : ?>
                <section class="front-page-section" id="static-page-content">
                    <div class="section-header">
                        <div class="container">
                            <div class="row">
                                <div class="col-sm-12">
                                    <h3><?php the_title(); ?></h3>
                                </div><!--/.col-sm-12-->
                            </div><!--/.row-->
                        </div><!--/.container-->
                    </div><!--/.section-header-->
                    <div class="section-content">
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-10 col-sm-offset-1">
                                    <?php echo $static_page_content; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            <?php endif;
        endwhile;
    endif;

    if( $sections_order_first_section ):
        illdy_sections_order( $sections_order_first_section );
    endif;

    if( $sections_order_second_section ):
        illdy_sections_order( $sections_order_second_section );
    endif;

    if( $sections_order_third_section ):
        illdy_sections_order( $sections_order_third_section );
    endif;

    if( $sections_order_fourth_section ):
        illdy_sections_order( $sections_order_fourth_section );
    endif;

    if( $sections_order_fifth_section ):
        illdy_sections_order( $sections_order_fifth_section );
    endif;

    if( $sections_order_sixth_section ):
        illdy_sections_order( $sections_order_sixth_section );
    endif;

    if( $sections_order_seventh_section ):
        illdy_sections_order( $sections_order_seventh_section );
    endif;

    if( $sections_order_eighth_section ):
        illdy_sections_order( $sections_order_eighth_section );
    endif;
endif;

get_footer(); ?>
2
  • Please post your answer yourself and accept it, feelings has nothing to do with your code, if it works for you share the solution so it can be removed from unanswered solution. Commented Jan 26, 2017 at 18:22
  • Saying "Can I feel comfortable in making this change?" was not actually a question about feelings. I wanted to know if this was a reliable and acceptable change. Sure, the change fixed my issue, but I wanted to know if this was an appropriate thing to do to the code and that it suffices as an answer. Commented Feb 1, 2017 at 1:02

2 Answers 2

2

It looks like you need to change your front-page.php page, you are using the wrong variable.

$static_page_content = get_the_content();

to

$static_page_content = the_content();

Edit: I see you just updated your question to this, yes this will work fine. Shouldn't see any negative side effects from this.

1
  • Comments are not for extended discussion and question edits are not considered answers.
    – Howdy_McGee
    Commented Jan 26, 2017 at 18:55
0

Good job you guy's ! I've tried this code and it works perfectly. I've just need to reduce the width of the front page.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.