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

  • Home
  • SEARCH
  • 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 8455845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:23:30+00:00 2026-06-10T12:23:30+00:00

I’ve created a portafolio custom type in WordPress and I would like to query

  • 0

I’ve created a “portafolio” custom type in WordPress and I would like to query a specific post (ID = 780 to be exact) in this code I’ve written, which retrieves all attachments images inside that post:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>


    <?php if ( $post->post_type == 'portafolio' && $post->post_status == 'publish' ) {
            $attachments = get_posts( array(
                'post_type' => 'attachment',
                'posts_per_page' => -1,
                'post_parent' => $post->ID,
                'exclude'     => get_post_thumbnail_id(),
                'orderby'           => 'menu_order',
                'order'           => 'ASC'  

    ) );?>

    <?php
            if ( $attachments ) {
                foreach ( $attachments as $attachment ) {
                    $class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type );
                    $thumbimg = wp_get_attachment_image_src( $attachment->ID, 'original', false ); ?>


    {image : '<?php echo '' . $thumbimg[0] . ''; ?>', title : '<?php wp_title("",true); ?>', thumb : ''},

    <?php               
                }

            }
        }
    ?>


<?php endwhile; endif; ?>

However, I don’t know where in that code I should query the specific post I want to retrieve.

Any ideas?

EDIT:

I have tried:

<?php
    query_posts( array('p' => 780) );
    if (have_posts()) : while (have_posts()) : the_post();
    ?>

    <h2>Test</h2>

    <?php endwhile; endif; ?>

Just to see if I was able to retrieve something, without luck.

If this helps, I am doing this so I can create a page on WordPress to display a single post of a custom type called “portafolio” and then assign it as frontpage.

  • 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-06-10T12:23:32+00:00Added an answer on June 10, 2026 at 12:23 pm

    You can change your query by calling query_posts before the loop:

    query_posts( array('p' => $myPostID) );
    

    Simply call this function before your loop. Your final code could be like this:

    <?php
    query_posts( array('p' => 780) );
    if (have_posts()) : while (have_posts()) : the_post();
    ?>
    

    You can specify even more parameters, like authors, or post-types, etc. Call rewind_posts() after endwhile; endif;, if you have another loop after your main loop.

    EDIT:

    A few comments later… be sure to add ‘post_type’ to your function, if you’re working with custom post types. For example:

    query_posts( array('p' => 780, 'post_type' => 'book') );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,

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.