• Resolved rikardo85

    (@rikardo85)


    Hello,

    I’ve created a custom post type for FAQs. These are displayed on the front end by using a shortcode which I’ve also created.

    Within this shortcode is the query to display all FAQs. (Code below)

    function team_list_sc() {
       ob_start();
       $member_args = array(
                   'post_type' => 'member',
                   'posts_per_page' => -1,
                   'order' => 'ASC',
                   'orderby'=> 'menu_order'
                   );
    
                   $internal_teammembers = new WP_Query( $member_args );
    
                   if( $internal_teammembers->have_posts() )
                   {
                      while ( $internal_teammembers->have_posts() ) : $internal_teammembers->the_post();
                      $role_field = get_post_meta(get_the_id(), 'teamRole', true); ?>
    
                           <div class="internalTeam floatLeft cleared">
                                   <div class="teamImage floatLeft">
                                           <?php if ( has_post_thumbnail() )
                                           {
                                                   the_post_thumbnail();
                                           }
                                           else { ?>
                                                   <img src="<?php echo get_template_directory_uri();?>/images/teamplacement.jpg" alt="<?php the_title();?>, <?php echo $role_field; ?>">
                                           <?php } ?>
                                   </div>
                                   <div class="teamContent floatRight">
                                           <h2><?php the_title();?></h2>
                                           <span><?php echo $role_field; ?></span>
                                           <?php the_content();?>
                                   </div>
                           </div>
                   <?php endwhile;
                   }
                   wp_reset_query();
    
    	$sc = ob_get_contents();
    	ob_end_clean();
    	return $sc;
    }
    add_shortcode ('team_list', 'team_list_sc'); ?>

    On the front end, the FAQs display like posts and not the styling that’s wrapped around the query (e.g div class=”teamImage”)

    Can some possibly guide me in the right direction to ‘over ride’ the blog’s style.

    In the Custom post type settings, I’ve used the arg ‘has_archive => false. I thought it was this but not.

    Any help much appreciated.

Viewing 9 replies - 16 through 24 (of 24 total)
  • Steve

    (@seekerabroad)

    In the code you posted above for your FAQ the last line says:
    add_shortcode (‘team_list’, ‘team_list_sc’); ?>

    I think you need to check the FAQ shortcode you created.

    The way I’ve used shortcodes, to call the code you’ve post above I would use [team_list] not [faqs].

    Either you’ve posted a different shortcode above or your caling a different one or I’m still misunderstanding?

    Thread Starter rikardo85

    (@rikardo85)

    I’ve edited the code to the below and still getting the same results when adding the shortcode to the page:

    function g5_contact_faqs_sc() {
           ob_start();
        $member_args = array(
    	    'post_type' => 'g5_faqs',
    	    'posts_per_page' => -1,
    	    'order' => 'DESC',
    	    'orderby'=> 'ID'
    	    );
    
    	    $internal_faqs = new WP_Query( $member_args );
    
    	    if( $internal_faqs->have_posts() )
    	    {
    
    	    $i=1;
    
    	       while ( $internal_faqs->have_posts() ) : $internal_faqs->the_post(); ?>
    
    	       <div id="faqWrap-<?php echo $i; ?>" class="singleFAQ floatLeft">
    		<h2><?php the_title();?></h2>
    		<div id="faqContent-<?php echo $i; ?>" class="faqAnswer"><?php the_content();?></div>
    	       </div><!--singleFAQ-->
    
    	    <?php
    
    	    $i++;
    
    	    endwhile;
    	    wp_reset_query();
    	    } 
    
    	/* Get the buffered content into a var */
    	$sc_faqs = ob_get_contents();
    
    	/* Clean buffer */
    	ob_end_clean();
    
    	/* Return the content as usual */
    	return $sc_faqs;
    
    } // End function
    add_shortcode( 'faqs', 'g5_contact_faqs_sc' ); ?>
    Steve

    (@seekerabroad)

    OK, So you’ve changed the shortcode and it’s not affected the page. In fact the shortcode seems to have never affected the page.

    This makes me wonder if the menu link actually points to the page you’ve created? In which case I would check the menu page and re-save it.
    I asked earlier if you had re-saved your permalinks?

    Thread Starter rikardo85

    (@rikardo85)

    I’ve managed to get it working.

    I saved the page as draft, previewed (all working fine), then published and checked and still working fine.

    Do you think it was a permalink issue?

    Steve

    (@seekerabroad)

    Whenever you move or change a wordpress site or change a url, one of the first things you should do is resave the permalinks.

    Well glad you got there in the end!

    Thread Starter rikardo85

    (@rikardo85)

    Thank you, I’ll definitely remember that.

    Can you point me in the right direction on how to do this?

    Thank for all your help.

    Steve

    (@seekerabroad)

    It’s very easy.

    From the WordPress dashboard, Click on Settings then Permalinks, then all you have to do is Click on Save Changes. You don’t need to change anything.

    Many times when my links don’t behave as they should I’ve done this and fixed it.

    I do it automatically now.

    Regards,

    Thread Starter rikardo85

    (@rikardo85)

    Brilliant, Thanks for all your help.

    Steve

    (@seekerabroad)

    No Worries ??

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘Custom post type not obeying styles’ is closed to new replies.