Change wordpress blog limit to months rather than by number of posts - wordpress

Is there a way to override how wordpress displays a number of posts on a listing of posts page, regardless of page type (archive, category, posts, tags etc.)?
I'm transferring content from a static site where the pages are saved using a month format.
I'd like to be able to set wordpress' previous/next link navigation to work using months, rather than the limit of posts per page.
So if the navigation would go forward/backward to the previous/next month where there is published content.
Thanks

Perhaps a WordPress Query will work?
Such as... (Not tested)
$month = date('m');
$query = new WP_Query( 'monthnum=' . $month );
As the WordPress Codex lists

Related

Replacing Wordpress Category with Static Page?

I'm rehashing a Wordpress question from 4 years ago that had an approved answer, but that solution no longer works in the current version of Wordpress. The original question: Make Wordpress use the page instead of category
Background (copied from originally approved answer):
example.com is the domain
I have a WP page called "foobar" with content
I have a WP post category called "foobar"
I have a WP post entitled "fun things to do with foobars", and the category is set to "foobar"
Expectations
When I go to example.com/foobar, I want to see the page about foobars, not a WP category page that shows all blog posts with that category.
When I go to the blog post about fun things, the URL is example.com/foobar/fun-things-to-do-with-foobars/
The solution at the time
There appeared to be a work-around with a custom permalink structure and using "." (no quotes) as the category base. That solution does not work with the current version of Wordpress.
There were also a couple of answers that suggested various plugins. I'm not overtly opposed to that route, but the suggested plugins at the time seem to have been affected by the same update that negated the accepted answer.
To load page with the same slug as of category name you could use following code snippet that replace category with Page.
function wpa_alter_cat_links( $termlink, $term, $taxonomy ){
if( 'category' != $taxonomy ) return $termlink;
return str_replace( '/category', '', $termlink );
}
add_filter( 'term_link', 'wpa_alter_cat_links', 10, 3 );
Be aware with the code. You should have pages for all your categories otherwise you will get 404 for those categories which have not created pages.
After adding above code into your activated theme's functons.php file please flush the permalink. You can do that with visiting settings -> permalinks -> click save changes
Hope it works for you!

WordPress: display full post AND excerpts on one page

Is there a way my category archive display both full posts and excerpts?
What I want is the first two or three latest posts display as full content posts, and all the others as excerpts with just title and a read more button. These are displayed on one page. I am currently using a category archive, on the twentyfifteen theme.
I know I can set a page to either display full or just excerpts, but not a combination. Is this possible?
Thanks!
You can get these in your wordpress loop on page or post.
<?php
$content = get_content($post->ID); //full content of post
$excerpt = substr($content,0,150); //you can limit charaacter like 150
?>

Custom WP_Query not working (listing featured articles + popular articles)

I am Wordpress beginer and I want to set multiple queries on a page that lists my posts.
Featured posts
I have front page that lists featured posts from all categories,
Categories pages that lists featured posts from current category
Q: Is it better to use My featured posts new category name or to set sticky post (under public - publish options) for posts I want to feature on front page and on categories pages? Every post already have his own category like News so the My featured posts will be the second category.
Query
Let's suppose I'm using category name for featured posts (but then i got permalink to My featured posts category (site/my-featured-posts/2013/07.....) which I don't want (so maybe sticky posts are better solution)
I'm trying to setup query to list featured posts but only from standard post type, not gallery or video
<?php
$arg = array(
'cattegory_name' => 'my-featured-category',
'posts_per_page' => 5,
'nopaging' => true,
'post_status' => 'publish',
'post_type' => 'post'
);
$featured= new WP_Query($arg);
if ($featured->have_posts()):
while ($featured->have_posts()) :
$featured->the_post();
?>
and then below the_title(); ..... and so on
What I get is all articles from all categories.
Q: Also, how to I get popular articles based on views and number of comments for the last day?
Q: How to list posts which have post format video?
Q: Are there any online tools that build wp_query based on criteria?
Thank you.
You can also set posts as "featured" using a tag. You can then use tag=featured with WP_Query to get posts tagged with a certain tag ("featured" in this example).
As for your additional questions...
Q1: You can save page views to a flat file or to the WordPress database. Once I used the database to store a UNIX-timestamp as traditional WP post meta for each post page view. As it was a timestamp, I could calculate the age of the page view easily (and I could also run SQL queries to remove post meta that was older than a certain timespan).
Comments can be queried by time ordering too. See WP_Comment_Query.
Of course there are plugins that can do this for you, but for me they included useless bloat I did not need.
Q2: For querying post formats, use the query variable called tax_query as GATEKeeper did in a WP support question: http://wordpress.org/support/topic/post-formats#post-2034414.
Q3: A google query returned a thing called The WordPress Query Generator.

Wordpress . How to move some post from front page to a different page?

I have 40 or so post on a WordPress site.
I need to move about 20 of them to a new page I created.
I have created to (New) page and a new category for these post.
I changed edit some of the post and changed the category to the new one.
They show up on the (New) page , but they all so show up on the Front page as well.
What needs to be done to get the post to just show up on the (New) page and not the Main page of the site.
Thanks for your help.
Exclude that category from the front page like so:
if ( is_front_page() ) { query_posts( 'cat=-1' ); }
Switch out the "1" with the ID of the category you want to exclude. The - sign in front of the ID says it is excluded.
Reference: WordPress Codex: Query Posts

Returning number of posts in Wordpress

I need a function to calculate the number of posts in a Wordpress blog that is aware if you are looking at a category, a given tag or the whole blog.
I'm keen to avoid rewriting for every different circumstance and want to make sure I get off on a reliable path. Relatively new to Wordpress any help appreciated.
Thanks
If you want to retrieve a count of all the posts in a blog, use wp_count_posts(). To get post counts from a specific category, do a count() on a call to get_posts() with the category ID specified as a parameter.
Example:
<?php
$posts = get_posts('category=1');
$count = count($posts);
echo $count;
?>
Unfortunately WordPress' wp_count_posts() function won't count a category's posts. It'll only count different post types, i.e posts, pages, drafts, and in 3.0, custom post types.
Provides a template function: WordPress › Count Posts « WordPress Plugins. Could borrow the code from it and integrate it into your theme's functions.php file.

Resources