Exclude post category in a blog page

In your functions.php file, use pre_get_posts and swap out the -1 in the following code with the category I.D you want to exclude from your posts page. function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-1’ ); } } add_action( ‘pre_get_posts’, ‘exclude_category’ );

Why aren’t paragraphs breaking on this page?

get_the_content() returns unfiltered content, and using a shortcode you cannot use the_content() to return filtered content as you cannot echo inside a shortcode. Your best option here will be is to applying the_content filters to get_the_content(), something like: apply_filters( ‘the_content’, get_the_content() ); EDIT Exact usage, replace $output .= get_the_content(); with $output .= apply_filters( ‘the_content’, get_the_content() … Read more

How can I add 2 buttons with shortcode

If I enter this shortcode: [download url=”http://example.com”]Download[/download] it works fine. But you have to enter the link text as content yourself. You might have missed that, the way I read your question. Your [demo]-Shortcode throughs an error. To see this, you need to have WP_DEBUG set to true: Notice: Undefined variable: func in \wp-includes\shortcodes.php on … Read more

Get the post id from a plugin

One of the problems I have run into while trying to accomplish something like this is: WHEN are you trying to get this information. A lot of stuff happens in a WordPress page request. See: https://codex.wordpress.org/Plugin_API/Action_Reference If you just have the raw function in your plugin file, it will try to run when the plugin … Read more

In what context should Categories and Tags be used

I think this is more a general question than a specific one and I’ll be treating it as such. Taxonomies in general are used to group posts together that shares the same characteristic. The post_tag and category taxonomies are the most widely and commonly used of the four build in taxonomies to achieve this. Also … Read more

What function publishes a post when you click the publish button?

Normally, posts are published by the wp_insert_post() function. Essentially, the post_status is changed from draft to publish. Nothing more to it than that, really. There is also the wp_publish_post() function, which is really only used for scheduled posts. It does the basic job of transitioning a post from “future” to “publish”, and also calls the … Read more

WP_Query custom field pass the post id

1st query: $exclude_post_top_stories=””; // WP_Query arguments $args = array ( ‘post_status’ => array( ‘publish’ ), ‘posts_per_page’ => ‘-1’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ); // The Query $exclude_query = new WP_Query( $args ); // The Loop if ( $exclude_query->have_posts() ) { while ( $exclude_query->have_posts() ) { $exclude_query->the_post(); // do something $exclude_post_top_stories[] = get_the_id(); } … Read more