Default CoursePress pagination in my custom template

I developed custom template pages, using CoursePress template. I wish to have the same pagination function as its default. I already have NEXt - PREV, but need page numbers also and the design. So examples:
please go to the homepage of my site and scroll down, you will see in BLUE 1-2 and the next

  • Predrag Dubajic
    • Support

    Hi Bela,

    Hope you're doing well :slight_smile:

    I had a look at your files and see that you are using completely custom templates in CoursePress parent theme, this is not a good practice because your customizations will be gone next time that CoursePress plugin has an update.

    I would suggest using child theme and I have attached it below so you can work on that instead.

    It seems to me that you need default numeric pagination there without the need to use CoursePress specific navigation.
    You should be able to accomplish that with one of the below guides and once it's in place we can help out with CSS styling to have it look like on courses page.
    http://www.wpbeginner.com/wp-themes/how-to-add-numeric-pagination-in-your-wordpress-theme/
    https://wordpress.stackexchange.com/questions/250861/resolve-numeric-pagination-custom-post-type

    Best regards,
    Predrag

  • Bela
    • Design Lord, Child of Thor

    Dear Predrag,

    Thanks for your reply!
    1) Yes I do not necessarily need CoursePress theme based pagination, however it would be great to be able to figure out how it works. Not only this specific function, but all the other functions. It is quite hard just looking the code.

    2) Thanks for the Theme attached. Please send me a recommended description how to work with child themes

    3) I will come back for the CSS when I am ready.

    Thank you!
    Bela

  • Bela
    • Design Lord, Child of Thor

    Hi,

    I need some help.

    This code does not work:
    Nothing is presented on the page when I add it
    <?php
    $pagination = get_the_posts_pagination( array(
    'mid_size' => 2,
    'prev_text' => __( 'Newer', 'textdomain' ),
    'next_text' => __( 'Older', 'textdomain' ),
    ) );
    ?>

    This line also does not present anything:
    <?php the_posts_pagination( array( 'mid_size' => 2 ) ); ?>

    However, the following to lines work properly, I use CoursePress Template:
    <?php echo get_previous_posts_link( 'Elöz?' );?>
    &nbsp&nbsp
    <?php echo get_next_posts_link( 'Következ?' ); ?>

    <?php echo $the_query->max_num_pages;?>

    Thanks!
    Bela

  • Predrag Dubajic
    • Support

    Hi Bela,

    You can read more about child themes here:
    https://developer.wordpress.org/themes/advanced-topics/child-themes/

    Basically you can activate child theme and add your template and custom codes in there so next time the CoursePress plugin has an update your theme files won't be affected.

    As for the pagination, I tried testing your theme on my installation but I'm afraid that the templates are highly customized and it's taking too much time to debug on what's going on with your custom templates.
    We do tend to help with any questions but the amount of custom code is pushing this over the scope of support we can offer here, you can read more about this here:
    https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-1

    If you need further development help it would be best hiring a developer to assist you further.
    You can also use our Jobs board for that:
    https://premium.wpmudev.org/wordpress-development/
    Please note that, no WPMU official staff members are allowed to work in the job board.

    Best regards,
    Predrag

  • Bela
    • Design Lord, Child of Thor

    Hi Predrag,

    Thank you for the reply.
    Well I would be a developer. I do not say I am super.

    Regarding the pagination.
    The CustomPress specific pagination is not working also the standard WP pagination.
    So there is some issue to figure out.
    I can create a clear site with CoursePress Theme where you can show a working example, so I can figure out how to make it work with my custom code.
    As I believe any developer need a working example to move forward.
    Is this solution work for you?
    Thank you,
    Bela

  • Predrag Dubajic
    • Support

    Hi Bela,

    About CustomPress pagination, can you check that you don't have same slug for the page and your post type or taxonomy as this is known to cause issues with pagination, you can check this discussion here:
    https://premium.wpmudev.org/forums/topic/custompress-pagination-not-working#post-1272950

    As for the custom post type pagination, I did some tests on my installation and when creating my own CPT and template it works fine, even with CoursePress pagination.

    I have tested this all on child theme that I have attached below so you can check it out.

    You can activate this theme and you will see that you now have Books custom post type, that one is registered in functions.php, so go ahead and create 3 or more book posts.

    After that create a new page and select "Books - Custom Template" as your template.
    Open the page and you should see a working pagination there.

    Note: If you can't see the new template in template selector that's due to WP 4.9 bug so you can activate this plugin to go around that bug:
    https://gist.github.com/westonruter/6c2ca0e5a4da233bf4bd88a1871dd950

    Hope this helps with proceeding further.

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.