• Resolved NM6

    (@himahuja)


    I want to use columns or grid whichever lets me split the content width, in a page-template. I tried to use the columns shortcode and also added the do_shortcode function to enable it in the template. But it doesn’t work; instead it breaks the layout.

    It will be better if I can have columns of uneven width. Has anybody else solved this in any other way?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hi NM6. The theme available in the wp.org repostitory doesn’t have built-in support for shortcodes. You could either upgrade to the version of the theme on the theme website or use a plugin like Shortcodes Ultimate.

    I use this one https://www.wpexplorer.com/symple-shortcodes/ it’s really fantastic, you can see what I used it for here and here. (theme layout set to 1 column)

    For eg. two 1/4 columns the shortcodes look like this:

    [symple_column size="one-fourth" position="first"]
    CONTENT HERE
    [/symple_column]
    
    [symple_column size="one-fourth" position="second"]
    CONTENT HERE
    [/symple_column]

    The shortcodes on the ‘Web Index’ page are used for columns and boxes, looks like this:

    [symple_column size="one-fourth" position="first"]
    
    [symple_box color="blue" text_align="left" width="100%" float="none"]
    <h4>FIRST BOX</h4>
    [symple_divider style="solid" margin_top="10px" margin_bottom="10px"]
    
    <a href="----" target="_blank">----</a>
    <a href="----" target="_blank">----</a>
    <a href="----" target="_blank">----</a>
    <a href="----" target="_blank">----</a>
    
    [/symple_box]
    
    [symple_box color="blue" text_align="left" width="100%" float="none"]
    <h4>SECOND BOX</h4>
    [symple_divider style="solid" margin_top="10px" margin_bottom="10px"]
    
    <a href="----" target="_blank">----</a>
    <a href="----" target="_blank">----</a>
    <a href="----" target="_blank">----</a>
    <a href="----" target="_blank">----</a>
    
    [/symple_box]
    
    [/symple_column]

    Thread Starter NM6

    (@himahuja)

    Hi bdbrown,

    Yes, I had downloaded both the theme and child master from the website. In my hueman > functions > shortcodes.php there is code for column shortcodes. In which case, columns should work. I’m guessing, to use them in a template instead of a normal page, do I have to add/enable somewhere else also?

    I don’t want to use Shortcodes Ultimate as its quite heavy, and since the theme already has support, it makes it bulky by using external plugin.

    #khunchay – Thanks for the suggestion. But when the theme has it, I’d prefer first to try and use that. I’d check them out for my other projects.

    I just tested the theme column shortcode in a post and it worked without any problems. Here is what I used:

    [column size="two-third"]...[/column]
    [column size="one-third" last="true"]...[/column]
    Thread Starter NM6

    (@himahuja)

    Yes, bdbrown, like I said above, it works on normal post, but I am trying to use it in my template file. Which sometimes needs using <do_shortcode> filter in functions.php, and I added that too. But still am unable to use it through the template. I guess there is some piece of code needed to enable the column shortcode to work via templates, which I am missing.

    Is the template file something you created? Or something generated by a plugin?

    Thread Starter NM6

    (@himahuja)

    I created a custom template moddifying single.php for my custom category.

    I just created a copy of single.php, renamed it, created a post with content that included the column shortcodes, selected the new page template file, and it displayed the columns without any problems. You mentioned a “custom category.” Is that something related to a plugin? Are you using any other plugins to create page layouts or content?

    Thread Starter NM6

    (@himahuja)

    @bdbrown,

    You’ve got me all wrong. First, I wouldn’t create a single-x.php if I wasn’t modifying it. Secondly, I am not using columns in the normal post. I am setting them up in the single-x.php template itself. Here’s a section of the code from my modified single-x.php:

    <?php while ( have_posts() ): the_post(); ?>
    			<article <?php post_class(); ?>>
    				<div class="post-inner group">
    
    					<h1 class="post-title"><?php the_title(); ?></h1>
    
    					<?php if( get_post_format() ) { get_template_part('inc/post-formats'); } ?>
    
    					<div class="clear"></div>
    
    					<div class="entry">
    						<div class="entry-inner">
    
    						<div class="facts group">
    
    						[column size="one-third"]
    							<div id="facts">
    							<h2>Facts</h2>
    							<ul>
    								<li><b>Climate - </b><?php the_field('climate'); ?> </li>
    								<li><b>Altitude - </b><?php the_field('altitude'); ?></li>
    								<li><b>Best Time to Visit - </b><?php the_field('best_time_to_visit'); ?> </li>
    							</ul>
    							</div>
    						[/column]
    
    						[column size="one-third"]
    							<div id="gmap">
    							<div class="responsive-iframe-container">
    							<p><?php the_field('google_map'); ?></p>
    							</div>
    							</div>
    						[/column]
    
    						[column size="one-third" last="true"]
    							<div  id="weather">
    							<p><?php the_field('weather'); ?></p>
    							</div>
    						[/column]
    
    						</div>
    
    						<!-- Introduction -->
    						<p><?php the_field('introduction'); ?> </p>

    the code in the divs within php tags is from ACF.

    OK, got it. Now I think we’re on the same page. To execute a shortcode in the template I think you need to do this:

    <?php echo do_shortcode('[column size="one-third"]'); ?>
       some code
    <?php echo do_shortcode('[/column]'); ?>

    Here’s the Codex reference.

    Thread Starter NM6

    (@himahuja)

    @bdbrown,

    Thanks for sticking with me so far…but it doesn’t work. That’s what confused me. I’ve done this earlier too, and if you look at my very first post, I had tried the “do_shortcode”. Usually you just have to put it in the functions.php once and that takes care of it. But I followed your version also, and put it in the single-d.php around the code yet it doesn’t activate the columns.

    I’m out of ideas other than a plugin conflict. You might give the “disable them all and test one-at-a-time” routine a try and see if that fixes it.

    Thread Starter NM6

    (@himahuja)

    @bdbrown,

    Finally I managed to find a solution for the columns, and that too from within the Hueman demo. On the columns demo page sourcode, Alex has used grid with column classes. I copied those and they worked, with minor tweaks!

    For those who might want to use columns in Hueman, here’s how:

    <div class="grid one-fourth"> content </div>
    
    <div class="grid one-half"> content </div>
    
    <div class="grid one-fourth last"> content </div>
    <div class="clear"> </div>

    You can easily mange your own combination of widths. Take a look at hueman style.css line 362 – base grid. And don’t forget to put “clear” after the columns to clear the floats.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Problems with columns and shortcodes’ is closed to new replies.