How to get a post’s content? [closed]

“best” greatly depends on context. guid is probably (with some debate about it) the best way to uniquely identify a post, but not all import/export plugins leave it alone without changes. ID is a good identifier if you do not care about import and export. Slug is problematic because they might be changed by the … Read more

the_excerpt() in content.php and get_template_part() in single.php

the_content() does not grab the PHP file content.php, it simply displays a Post’s content. Likewise, the_excerpt() grabs the excerpt of a post. get_template_part simply finds a file within your theme named whatever you put in, with an optional suffix. get_template_part( ‘content’ ); // content.php get_template_part( ‘content’, ‘my_page’ ); // content-my_page.php in order for make different … Read more

WordPress page content outside WordPress

The alternative way. Problem with @david.binda solution is that: you have to hardcoding a lot of things, (manually write db credientials, table prefix..) You cannot use content filter (so if you have shortcode in your page, you will see some [something] instead of desired content..) sure you can load wordpress environment, but… Just yesterday I … Read more

How do I find PHP file that contains content of my page?

You are under a fundamentally wrong assumption: The content you input via the administrative back-end does not live in a file, but in the database, specifically in the wp_posts table. Do not be misguided by the table’s name, a “page” is technically a post of type page. If you attempted to find the content you … Read more

How do I display an image before the first post of the loop when I’m using get_template_part?

The variable $count is accessible in the scope of the current function only. So whatever happens inside get_template_part() cannot know that variable. You could use a global variable, which is accessible everywhere as $GLOBALS[‘count’]. But then you risk collisions with plugins and maybe other code. I recommend a helper function for the functions.php: /** * … Read more

What is the precendence of item types within WordPress

The precedence is determined by the order of the rewrite rules: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/class-wp.php#L196 These map the structure to a query, which is then fed to WP_Query, which has its own defaults. I don’t see why you would be landing onto the media post, the post_id does not match, there should not be any collision in the … Read more