Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7572703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:59:30+00:00 2026-05-30T15:59:30+00:00

I use WP plugin Custom Post Type UI and a template of my own

  • 0

I use WP plugin “Custom Post Type UI” and a template of my own to add some content to my wp page.

<div id="AboutMain">
<?php 
    /* the original page contents */
    while (have_posts()) {
        the_post();
        get_template_part('content', 'page');

    /* New set of data fetched from my custom post types */
    $posts = get_posts(array(
        'numberposts' => -1,
        'post_type' => 'styrelse'
    ));

    if($posts)
    {
        foreach($posts as $post)
        {

            $namn=get_the_title($post->ID);
            $desc=get_the_content($post->ID);

            echo "
            <div class='styrelsen art-postcontent'>
                <h5 class='art-postcontent'>$namn</h5>
                <p>$desc</p>
            </div>
            ";  
        }
    }

Now I get a really strange behavior – since I have set the $posts with a custom query, in the for-each loop it should not contain the basic page contents anymore but my custom post type content right?

But the get_the_content($post->ID); fetches me the original contents of the page, and repeats it over and over while the get_the_title($post->ID); retrievs for me the correct title.

******** solved *************‘

OK, here’s how I did it.

first I realized that using that global variable name might not be the best idéa so I changed it to $board_posts.

Then I dumped that variable to find out how to access the title and body ‘manually’ and it turns out it was easier than I first thought.

foreach($styrelse_posts as $post)
{   
$namn = $post->post_title;
$desc = $post->post_content;

trial and error beats most issues =)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:59:32+00:00Added an answer on May 30, 2026 at 3:59 pm

    Using $post as a variable can cause some weird behavior because of how WordPress uses that as a global variable. I’d suggest trying either calling setup_postdata($post) before get_the_title($post->ID), or maybe changing the foreach to foreach($posts as $p) and using $p->ID as the argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I regularly use the jQuery jScrollPane plugin to add custom scroll bars to page
Is there any plugin available which I can use to post custom content on
I'm trying to use a custom validator with jQuery Validation plugin. However, I'm unsure
I am developing a custom plugin where is make use of groovys HTTPbuilder everything
I'mt trying to create a plugin which adds a custom page in the admin
I have a custom plugin for 3ds Max that interfaces with some managed code
I use the assembly plugin to create several jars with some classes in it.
Is there a way (or a plugin) to make a given content type in
I have a similar problem with this ( https://wordpress.stackexchange.com/questions/9593/custom-post-type-archive-with-pagination ) and can't really figure
I try to use timepickr plugin, from http://haineault.com/media/jquery/ui-timepickr/page/ my headers: <script src=<%=ResolveUrl(~/Scripts/jquery-1.4.2.min.js)%> type=text/javascript></script> <script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.