Articles of posts

Is there a better, more efficient way to get the post id outside the loop?

Right now I am using: $wp_query->post->ID; I want to know if there is a better way for getting the post id that consumes less resources?

custom single.php not working

Trying to solve this issue for the past hour and I can’t figure out what’s going on. Trying to create single-blog.php (I have a few posts which are under the category ‘blog’) but WordPress automatically redirects these posts to single.php! I’ve flushed the permalinks by settings > permalink > save changes but still nothing happens. […]

Specify number of posts in my 'tax_query'

I’m showing posts of the term ‘football’ belonging to the taxonomy ‘section’, and everything works perfectly but Where can I specify the number of posts I want to show? just like this: ‘showposts’ => 3 I do not know where to put it $myquery[‘tax_query’] = array( array( ‘taxonomy’ => ‘section’, ‘terms’ => array(‘futbol’), ‘field’ => […]

When trashing a post, also trash related comments

As it is now, when I trash a post, the related comments get deleted at once. Is this standard? Instead I’d like them to be moved to the trash bin, when I trash the post. How can I achieve this? I can’t seem to find a solution.

setup_postdata doesn`t seem ot be working

I’m having issues with setup_postdata(). From my understanding, if I want to use functions such as the_permalink() or the_title(), I must use setup_postdata(). Right now, the_permalink() or the_title() is returning nothing (blank). I’ve also tried echo get_the_title() to see what happens but even that yields the same result. Here is the code the relates to […]

Trying to edit the single page from a Custom Post

I have a custom post type where I can create pages in.(“article.php”) It automatically uses the template “single.php” when I create a page, although I want to change some things in it without effecting some other pages on the website. I tried making a single-article.php file, but it is still using the single.php template page. […]

Display content from a specific category

I’m trying to get my news page to display content from one category only (number 3) but I cant seem to get it to work. Instead of just displaying posts from category 3 it displays posts from all category’s. Here is my code: <?php get_header(); ?> <div class=”content news_page”> <h1>Latest News</h1> <?php $args = array( […]

Including text at the end of every post

I would like to include some text at the end of every post. Like how some people write “Like my posts? Follow me on twitter!” or something like that. There are some buttons for users to tweet or share the posts, but I want to see how people would respond to explicit suggestions. I thought […]

Only display a certain number of posts, dependent on how many posts there are available in a query

I am trying to write some code for a slider of posts, at the moment my code involves two WP_Querys, one inside the other, but I can’t help feeling there may be a more efficient way of doing what I’m trying to achieve. Steps are: Check how many published posts there are of a certain […]

Enabling post thumbnails for custom post type

I’m writing a custom post type as a plugin and trying to figure out how I can enable post thumbnails within plugin documentation/template instead of enabling it in the functions.php. I tried adding the code below inside custom-post-plugin.php and it doesn’t seem to work. I still have to write the code within the functions.php to […]