• Hello!

    The title explains the problem: Shortcodes don’t work on my pages. I have reverted to one of the default themes and they work. Which means it’s a problem with the theme I coded.

    Here is the code:

    <?php $postcount=1;
    
    		while ( have_posts() ) : the_post();
    		if( ($postcount % 2) == 0 ) $post_class = '';
    		else $post_class = clear ;
    ?>
    
    		<div class="postlist <?php echo $post_class; ?>">
    		 <div <?php post_class(); ?>>
    
    <?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
      ?><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail();?></a> <?php
    }
    ?>
    				        	<?php the_content();?>
    
    				</div><!-- /.post_class -->
    		</div>
    			<?php $postcount++; endwhile; ?>
    			<?php bootstrapwp_content_nav('nav-below');?>

    I’ve researched this and found that not using <?php the_content(); ?> can cause the problem. However, I am using it here.

    Any help would be greatly appreciated. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • I can’t see anything obviously wrong in the code above. You have a Loop running and you’re using the_content() – which is what most shortcodes need in order to be expanded. I would suggest that the issue lies elsewhere in your theme. I couldn’t say for sure where that would be but functions.php might be a good place to start or in any file where you are manipulating post content.

    Thread Starter allegrovivo

    (@allegrovivo)

    Thanks for the response, Esmi.

    There is nothing in my child theme’s functions.php

    The parent theme is BootstrapWP

    Do you have the same problem when using the parent theme?

    Thread Starter allegrovivo

    (@allegrovivo)

    Just tried it, it works fine.

    I do have several templates. This page is using the “Default Template” template. That’s page.php, right? If so, then I did give you the correct code above.

    Maybe it’s something in header.php?

    <html <?php language_attributes(); ?>>
      <head>
    
    	  <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,400,700,300' rel='stylesheet' type='text/css'>
    
    	  <link href='https://awebfont.ir/css?id=1047' rel='stylesheet' type='text/css'>
    
       <title><?php
      /*
       * Print the <title> tag based on what is being viewed.
       */
      global $page, $paged;
    
      wp_title( '|', true, 'right' );
    
      // Add the blog name.
      bloginfo( 'name' );
    
      // Add the blog description for the home/front page.
      $site_description = get_bloginfo( 'description', 'display' );
      if ( $site_description && ( is_home() || is_front_page() ) )
        echo " | $site_description";
    
      // Add a page number if necessary:
      if ( $paged >= 2 || $page >= 2 )
        echo ' | ' . sprintf( __( 'Page %s', 'bootstrapwp' ), max( $paged, $page ) );
    
      ?></title>
        <meta charset="<?php bloginfo( 'charset' ); ?>" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <?php if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); ?>
        <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    
      <!-- Le fav and touch icons -->
        <link rel="shortcut icon" href="<?php bloginfo( 'template_url' );?>/ico/favicon.ico">
        <link rel="apple-touch-icon-precomposed" sizes="144x144" href="<?php bloginfo( 'template_url' );?>/ico/apple-touch-icon-144-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php bloginfo( 'template_url' );?>/ico/apple-touch-icon-114-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php bloginfo( 'template_url' );?>/ico/apple-touch-icon-72-precomposed.png">
        <link rel="apple-touch-icon-precomposed" href="<?php bloginfo( 'template_url' );?>/ico/apple-touch-icon-57-precomposed.png">
    
      <!--[if lt IE 9]>
    <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
        <?php wp_head(); ?>
    
      </head>

    [Moderator Note: No bumping, thank you.]

    What theme are you using? Where did you download it from?

    Thread Starter allegrovivo

    (@allegrovivo)

    (Sorry about violating the no bumping rule)

    This is a custom theme created for this client. One of our past designers on our staff wrote this, not me, so I don’t know the details of why they coded it this way.

    I’m sorry but we cannot really help with custom themes as we have no idea how they were constructed. I can only suggest that you contact the original developers of the theme or try hiring someone to look into this for you. That said, I cannot see any issues in the code you posted above.

    Thread Starter allegrovivo

    (@allegrovivo)

    Okay, will do. Thanks for your help, Esmi! I see your posts on threads that help me with other problems and I always appreciate the help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Shortcodes don't work’ is closed to new replies.