WordPress display page information rather than post

I figured out a solution. It works, not entirely sure if it’s best practice but I queried the posts first and it seems to show up. Here’s my code; <?php query_posts(‘showposts=2’); if (have_posts()) : while (have_posts()) : the_post(); ?> I then closed the if statement with; <?php endif; wp_reset_query(); ?>

How can I exclude only a specific sub category post from category display?

Ended up doing this (if the relevant post’s ID is, for example, 5): function filter_posts($query) { if ( $query->is_category() && $query->is_main_query()) { $this_category = get_queried_object(); if (0 == $this_category->parent) // Category has no parent $query->set(‘post__not_in’, array(‘5’)); } } add_action(‘pre_get_posts’, ‘filter_posts’);

calling pages instead of posts

This was already answered in the comment by Jack, but what you would do is add &post_type=page at the end of the WP_Query call. https://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters Your revised query call: $my_query = new WP_Query(‘showposts=”.$show.”&orderby= ‘ . $orderby . ‘&order=” . $order . “&post_type=page’);

how to call recent post content in a loop ( only the content before read more tag)

for latest 5 post you can use this code: $args = array(‘post_type’=>’post’, ‘posts_per_page’=> 5); $query = new WP_Query($args); if($query->have_posts()): while($query->have_posts()):$query->the_post(); echo ‘<li>’; $content = get_the_excerpt(); //for featured image if(has_post_thumbnail()): the_post_thumbnail(); endif; print $content; echo ‘</li> ‘; endwhile; wp_reset_postdata(); endif; In case you want to change word count in excerpt use this action hook function. /** … Read more

Add post id as body class in wordpress admin dashboard [duplicate]

Not sure to completely got your question, but if you are looking for a way to have in the editor the same classes you are using in the frontend, put an editor-style.css file in your child theme folder and fill it with the classes you need (i.e.:body). Then in your functions.php, add this line: add_editor_style(‘editor-style.css’);