Post Category link is same with Page link
You can setup a custom link structure in the Permalink Settings. There is a field for ‘category base’ name.
You can setup a custom link structure in the Permalink Settings. There is a field for ‘category base’ name.
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(); ?>
So I just found this filter: the_posts https://codex.wordpress.org/Plugin_API/Filter_Reference/the_posts Send it to a function, and the first parameter is the entire post page with the pagebreak. My plan is to run it through regex, delete the first occurence of the <!–nextpage–> and return it. I’ll see if that works
This one has tripped me up in the past. If you have a collision between a taxonomy and post type rewrite, it’s important that you register the taxonomy before the post type. Assuming you’d be ok with reworking your reviews URLs to the format /reviews/%niche%/%postname%, you’d need to change your post type as follows: ‘rewrite’ … Read more
Use the following snippet to track post views on your wordpress blog. The first thing you want to do is add this snippet to the functions.php of your wordpress theme. Follow step 1. and step 2. to track and display the number of views for each post. Credits to the author here on this post … Read more
The problem is that the rewrite rules overlap, WordPress is trying to find a category name that matches the post slug. A possible solution is to do a little manual query parsing, check if the request contains category_name and is a term first, and reset query vars to post name if nothing is found: function … Read more
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’);
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’);
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
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’);