Pagination With Special Recent Posts Plugin (WordPress) - pagination

I am using the 'Special Recent Posts' plug-in in WordPress. It is being used to show header images and excerpts for articles, which you then click through to the full article.
You can set parameters on that plug-in to tell how many recent articles you would like show. Basically what I want to do is show the first five articles on the main page and then have the overflow go to new pages (like an 'older posts' type thing where there would be five posts per page).
Can anyone help me get pointed in the right direction? Every time I Google this question it doesn't quite understand...Thanks.
EDIT:
I saw the first answer and while it is moving in the right direction, it doesn't automatically generate the new pages like I would like. I want to have the overflow of special recent posts generate a new 'previous' page automatically. I understand that I could manually do this but the blog I am working on will be getting updated every day so it would be very time consuming to constantly create new pages as I go along. Can somebody point me in the right direction?
EDIT:
Here is the full code I have on my index.php:
<?php get_header(); ?>
<?php c2c_the_category_image($image_extensions='png gif jpg', $image_dir='/wp-content/images/', $use_name_if_no_image=true, $start_from='begin', $limit=999); ?>
<?php echo do_shortcode("[srp srp_number_post_option='34' srp_thumbnail_option='yes' srp_widget_title_hide_option='yes' srp_post_date_option='no' srp_wdg_excerpt_length='50' srp_wdg_excerpt_length_mode='fullexcerpt']"); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

The plugin has a parameter for this, from the documentation:
//Global Post Offset (to skip an arbitrary number of posts from the beginning)
srp_post_global_offset_option => numeric
So, on the second page, to skip 5 posts and then show the next 5, you would want something like this:
[srp srp_number_post_option='5' srp_post_global_offset_option='5']
Documentation: http://wordpress.org/extend/plugins/special-recent-posts/installation/
EDIT: To answer your question about generating new pages, technically you would not. You would have one page that would show different posts, acting like it was a different page. You would probably need use a query string (URL parameter). But, you can't put direct PHP into a wordpress post, so you need to either modify a PHP file, or get a WordPress plugin like Shortcode Exec PHP, so you can take the page number parameter from the URL and put it into the shortcode for special recent posts.
Example based on your index.php code:
$offset = ($_GET['page'] * 5) - 5;
echo do_shortcode("[srp srp_number_post_option='34' srp_thumbnail_option='yes'
srp_widget_title_hide_option='yes' srp_post_date_option='no'
srp_wdg_excerpt_length='50' srp_wdg_excerpt_length_mode='fullexcerpt'
srp_post_global_offset_option='".$offset."']");
Make your first page use
index.php?page=1
And your "Next Page" link:
$next = $_GET['page'] + 1;
echo 'Next Page';

I never worked before the special recent post plugin. So i would like to give WordPress query post solution.
First, to get recent five post in home page (index.php) use below query parameter.
$query = new WP_Query( 'posts_per_page=5');
Second, to list older post in other page use below query parameter.
$query = new WP_Query( array( 'posts_per_page' => 5, 'offset' => 5 ) );
Above query will get posts from 6 and 5 post per page.To add pagination, add paging parameter.Refer WP_Query

Pagination is now available in the new Special Recent Posts PRO Edition version 3.0.0

Related

Kentico 9 blog main page, archive page, and tag page

I'm new to Kentico, and have spent hours trying to make the blog work but haven't had any luck. Hope someone could help. I created a new blog by [a] using Pages > New Page > Blog; [b] then applying the Blog page template to it; [c] after that I created 2 sample blog posts. The only thing that works is the individual blog post. Other things don't work:
1- the blog main page --> empty
2- the blog archive page (for July) --> empty
3- tag link --> error message "Page /Blogs/My-blog-1.aspx was not found." Although I know I can change the tag link url, not sure what should be in there.
4 - making "Blog" appears on my nav (that I used CSS List menu web part). For this one, as a workaround, I was thinking about adding a blank "Blog" page and had it redirected to the blog url.
I've read the documentation related to Blog, but couldn't make it to work. Thanks for help!
Some of the out of the box templates are setup in such a way to only work on some of the example site templates which is why you're getting these results.
In the rptAllPosts repeater, set the Path property to ./%, ensure the Page types property is set to cms.blogpost, make sure you have a value in the Transformation property as well.
Should be resolved when you finish #1
You will have to modify the Selected Transformation. If you're using the default transformation, about line 9, way at the end you will need to modify the last parameter from ~/Blogs/my-blog-1.aspx to ~/Blog. This should fix the blog tag link.
Your work-around is very common and I'd stick with it for now.

Wordpress: Display content from a Custom Post Type within a regular Post

I feel like there is a really simple solution to this problem. However, after trying to solve it for about 3 hours unsuccessfully, I humbly come to you.
The Basics:
A custom post type, " band ", has been created, and has several
custom fields (which were created through the Advanced Custom
Fields
plugin.)
The Question:
How would I get and display the contents (specifically custom field data) of a specific band entry (using its ID or title or slug) inside of a regular post? (see diagram below)
(source: thisnewband.com)
.
Methods to Trigger the Display of the Custom Post Type:
We have to provide the ID/title/slug so that it knows what band post's content to display
Shortcode (such as [band id="21"] ) (added inside post content)
Custom Field (custom field name band-id where you can input the ID of the band)
What I've Tried and Why It Didn't Work:
Shortcode
`[band id="21"] inserted in post editor field
Used WP_Query to query post with type=band and ID="21".
Code located in functions.php
Result: It would echo static text but would not display any post-specific content (Band Name, etc.). Also would not pull post-specific custom field data.
(also tried query_post with no luck)
Custom Field
Entered ID (21) into custom field on post editor page.
Coded it directly into the post template:
Used WP_Query and had the ID in the array pull from the custom field.
Result: Nothing good happened.
Where I Keep Running Into Trouble:
It's hard to pull the custom field data from the custom post type while inside an actual post
The Optimal Solution:
Whether it's by using a shortcode, custom field, or even a new widget, it would be easiest if one could:
Create a PHP template with the code for just how the single Band content is supposed to display. (Including the loop). Example name: band-block.php
Use get_template_part('band-block'); to echo this code (either in Post Template or Shortcode via functions.php)
Thanks for your help! Let me know if you'd like to see any of my code.
I knew you have found a solution for your problem, but for others i will give them an other solution:
You can query by ID, no problem. Look at these: http://www.advancedcustomfields.com/resources/field-types/relationship/
But you have to check in the custom field "return format" the box "Post IDs". Then it works perfectly well.
Sorry for my bad english ;)
Cheers
With some amazing help from Hobo, I was able to come up with a solution!
The main problem was with trying to query by 'ID'. No matter what we tried, it just never worked well. (It could be the way that the Advanced Custom Fields stored the ID field contents.)
What did work:
Created a custom field for the post page in which to put the Band (custom post type) post name/slug into. (Custom field was named post-band-name and created with the Advanced Custom Fields plugin.)
Placed the query code in the Post Template. (See code below)
Done.
The Solution Code
Add this loop after the normal loop...
<?php /* Display all the author's posts from the custom post type ('band') */ ?>
<?php
$authorid = get_the_author_meta( ID, $userID );
$args4=array('author'=>$authorid,'post_type'=>'band', 'numberposts'=> -1);
$cquery4=new WP_Query($args4);
if($cquery4->have_posts()):
while($cquery4->have_posts()):
$cquery4->the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<p><?php the_title();?></p>
</a>
<?
endwhile;
wp_reset_postdata();
endif;
?>

Pagination [+next+] not working on MODx CMS template

I'm having difficulty getting the pagination functionality working with [[Ditto? ... ]] in MODx CMS.
I have the documents displaying in the page, limit is set to 5. The output from my other pagination template placeholders seem to be working but the [+next+] link doesn't load the next set of 5 documents (going in descending date order).
Here's my template code:
[[Ditto?
&parents=`13`
&tpl=`ArticleListChunk`
&display=`5`
&&removeChunk=`Comments`
&paginate=`1`
&extenders=`summary,dateFilter`
&paginateAlwaysShowLinks=`0`
&dateFormat=`%F %D %Y`
]]
<p>Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles</p>
<ul class="clearfix">
<li>[+previous+]</li>
<li>Page <strong>[+currentPage+]</strong> of [+totalPages+]</li>
<li>[+next+]</li>
</ul>
The output I get is:
Showing 1 - 5 of 17 Articles
Page 1 of 4
Next >
as you can see the output is correct, however when I click the 'next' link the resulting URL is .../news.html?start=5 but the content of the page stays the same (i.e. the latest 5 documents are shown!).
This is how the template and functionality was when I was inherited this project from a client, and I have never used MODx CMS before -- can anyone help me please?
I there a way to update the SQL offset with a parameter or something? I've been all through the Wiki pages for Ditto / MODx but can't find what I need or what I should be doing that I'm not!
I would think you need to call ditto uncached [[!Ditto? attribs ]]
That's just a guess.
Also it looks like you are using EVO? check the cache syntax, you might need to put an exclamation mark at the end as well. [[!Ditto? attribs !]]
After plenty of searching I found a post on the MODx forum that pointed me in the right direction.
Turns out that caching was enabled in the page/document's settings (doh!). I disabled this and now it works fine!
However I have not set the no-caching token ('!') in Ditto's parameter string which, including the answer from Sean, my research has suggested is advisable and/or required. I've not worked with MODx before so I can't say for certain, but it seems to work without this for me!
Thanks #SeanKimball as your answer set me down the right path.

Strange pagination 404 issue with custom post type

I have a really strange problem trying to paginate custom posts types in their archives page, I created a custom post type called property and set an archive page called properties to show them all.
So inside my archive-property.php file added a form (GET method) with a dropdown box so users are able to set how many posts they want to display per page, it looks like this:
<select name="prop_number" id="prop_number">
<option value="12">12</option>
<option value="25">25</option>
<option value="50">50</option>
</select>
So before everything I do:
if (isset($_GET)) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query_args = array(
'post_type' => 'property',
'paged' => $paged,
'posts_per_page' => 12 // Default number of properties per page
);
// Custom number properties per page
if (isset($_GET['prop_number']) && !empty($_GET['prop_number'])) {
$query_args['posts_per_page'] = $_GET['prop_number'];
}
}
query_posts($query_args);
// Do loop and other stuff
It works fine but when I use next_posts_link() to get to the second page I get a page not found 404 error, however if I go to my WP admin area and set the "Blog pages show at most" option to the same number I want per page in my select box (for example I manually set 25 on "Blog pages show at most" and select 25 in my prop_number select box) it does work fine.
I even tried using the WP-PageNavi plugin and it does render the correct amount of numbers depending on how many properties I want to show but I have the same problem 404 pages on any page I try to go unless I manually set the page in the backend.
If I didn't need the option to choose how many properties I want to show I'd just set the number manually but since users can choose between 3 options I can't set this to a fixed number in the backend.
Could anyone tell me what's wrong? Thanks in advance!
I'm not sure if you ever resolved your issue, but for the sake of anyone finding this question you may want to try flushing your permalink structure.
From http://codex.wordpress.org/Rewrite_API/flush_rules:
//Ensure the $wp_rewrite global is loaded
global $wp_rewrite;
//Call flush_rules() as a method of the $wp_rewrite object
$wp_rewrite->flush_rules();
Put that in your functions.php file, refresh your page, and see if that fixes your problem. It has for me in the past when I've had pagination 404 issues.
NOTE: once you have flushed your permalinks, remember to erase those two lines (see above) as you do not need or want that running every time a page is requested - it only needs to be done once. (This entire action may or may not be the same as going to the Permalinks page in your admin console.)

Pagination on Propel ORM

i paginated the propel results, its all working fine, but i cant get this thing working. I will really appreciate any help or workaround this issue:
<?if ($posts->getPage()==???) { ?>
next
<?}?>
the function getPage() returns to me the active page, but what should i put on the ??? to hide the last next link on propel, some function like $posts->getLastPage() that actually works. I just cant get any info about this on the Propel documentation.
to hide the first 'previous' link, i used this:
<?if ($posts->getPage()>1) { ?>
prev
<?}?>
getLastPage() will return the page number of the last page. atLastPage() is a convenience function that will already do the comparison for you, and also exists as atFirstPage(). See the API docs for Propel 1.3, 1.4, 1.5 or 1.6.
You code could look like this:
<?php if (!$posts->atLastPage()) { ?>
next
<?php } ?>
I assumed $linkPrevNext contains just the page numbers, like it came from $posts->getNextLinks(). If not, you should not use getLastPage() in the link of course.

Resources