• 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 15 replies - 1 through 15 (of 24 total)
  • Steve

    (@seekerabroad)

    Hi,

    Could you post a url to the page, so that we can see what is being served to the browser?

    Regards.

    I would use a code editor like the FireBug Extension in FireFox and examine the page and element in question to see what CSS is being applied. It could be that your css is not specific enough.

    without the url it is hard to tell. What is the CSS you coded for the class ‘teamImage’ and were did you put it? Have you made sure you spelled it right and used the correct upper/lower case?

    Thread Starter rikardo85

    (@rikardo85)

    Steve,

    Thanks for the reply. Please see link below:
    https://www.cambridgeacademicperformance.co.uk/faq/

    Steve

    (@seekerabroad)

    Hi Rikardo,

    I’ve had a look at your FAQ page.

    Please correct me if I’m wrong, but the query you posted above does not look like a query for your FAQ page.

    In fact it seems to match your about / team page?

    This has me a bit confused?

    Regards,

    Steve.

    Thread Starter rikardo85

    (@rikardo85)

    The FAQ page is displaying a list of posts from a custom post type (FAQs).

    I’m using the query in the code above to generate the list of FAQs.

    The issue is that for some reason list has reverted to a list of posts (like the blog page), removing the divs and styling etc (code shown above). Looking further at the code, the body has been given a class of ‘blog’.

    On a previous test site, the body had a class of ‘post-type-faqs’ and all styles in the code above where present.

    juggledad,
    Yeah I’ve investigated that way. None of the HTML is being picked up from the code posted above.

    Hope that helps

    are you sure you have your short code on the FAQ page?

    Thread Starter rikardo85

    (@rikardo85)

    Yeah, its on the page.

    Looking further, the code is being used to style etc is coming from content.php.

    The shortcode is generating the posts but content.php is used to style / add divs etc.

    Steve

    (@seekerabroad)

    What is the custom post type name for your FAQ posts?
    Is the code you posted the entire shortcode?

    Thread Starter rikardo85

    (@rikardo85)

    it’s called g5_faqs

    I had this working in a test site perfectly. Once moved to a live environment, the changes occurred.

    Steve

    (@seekerabroad)

    OK, I certain that query is selecting your members custom posts, but even that is not showing?

    What step did you take in moving to a live environment? Did you resave your permalinks at the new location?

    Thread Starter rikardo85

    (@rikardo85)

    I ran a domain name change script to change the beta urls to the live url.

    e.g. beta.testsite to cambridgeacademicperformance.co.uk

    Steve

    (@seekerabroad)

    OK.

    How are calling the shortcode? Are you adding a [shortcode] to a page? If so, what’s inside the [ ]?

    Thread Starter rikardo85

    (@rikardo85)

    I’m calling the shortcode in the page using [faqs]

    Steve

    (@seekerabroad)

    And what’s inside the [ ] shortcode for your team page?

    Thread Starter rikardo85

    (@rikardo85)

    [team_list] is on the team page

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