Tagged: x
-
AuthorPosts
-
January 10, 2017 at 10:37 am #1324127
mateoserendipiaParticipantHi,
I’ve built a portfolio page that shows one post per project. I have The Grid to provide visitors a choice between links to other projects (see link in next private message). However, I also wanted to include two additional links to the previous and next project (posts). Guided by some threads on this forum I’ve included the code below in my child-theme’s function.php. This works fine but the links appear always at the bottom of the page, so always under the content of the post. From the code I can understand why this is, but I would rather be able to have these links appear somewhere else on the post (above the grid-menu, in my case.)
So my question would be: is there a way to include some code in cornerstone to have these links appear in the post, rather then always at the bottom? So essentially, to show the results of the $posts declaration somewhere else? I experimented with the raw-box, but without luck. Then again, i’m not a php-whizkidd, so perhaps I’m asking something the impossible…
This is the code I implemented in functions.php
add_action ('the_content', 'add_next_post_item_link' ); function add_next_post_item_link ( $content ) { if ( is_singular('post') || is_singular('x-portfolio') ) { $next_name = "volgend project <i class=\"x-icon-chevron-right\" data-x-icon=\"\"></i>"; $prev_name = "<i class=\"x-icon-chevron-left\" data-x-icon=\"\"></i> vorig project"; $next_link = get_next_post() ? '<a style="float: left;" href="' . get_permalink( get_next_post()->ID ) . '">' . $prev_name . '</a>' : ''; $prev_link = get_previous_post() ? '<a style="float: right;" href="' . get_permalink( get_previous_post()->ID ) . '">' . $next_name . '</a>' : ''; $posts = '<div class="wp-post-navigation-next">'.$next_link.$prev_link.'</div>'; return $content . $posts; } else { return $content; } }Thanks!
January 10, 2017 at 10:39 am #1324130
mateoserendipiaParticipantThis reply has been marked as private.January 10, 2017 at 12:23 pm #1324284
RupokMemberHey there,
Thanks for writing in! Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.
Thank you for your understanding.
January 10, 2017 at 12:36 pm #1324300
mateoserendipiaParticipantHi,
Thanks – however, this was a standard answer. I wasn’t describing in issue, and I haven’t customised anything beyond the use of one your integrated plugins. The code I implemented can be found at this forum (and was provided by your people), and this code works fine, as can be seen at the provided URL.
What I was enquiring about was if it is possible to have these two links to previous and next posts appear anywhere else than at the bottom of the page, so to include them somewhere in cornerstone.
Thanks.
January 10, 2017 at 11:12 pm #1325025
LelyModeratorHi There,
Try using this code instead:
function prev_next_link() { if ( is_singular('post') || is_singular('x-portfolio') ) { $next_name = "volgend project <i class=\"x-icon-chevron-right\" data-x-icon=\"\"></i>"; $prev_name = "<i class=\"x-icon-chevron-left\" data-x-icon=\"\"></i> vorig project"; $next_link = get_next_post() ? '<a style="float: left;" href="' . get_permalink( get_next_post()->ID ) . '">' . $prev_name . '</a>' : ''; $prev_link = get_previous_post() ? '<a style="float: right;" href="' . get_permalink( get_previous_post()->ID ) . '">' . $next_name . '</a>' : ''; $posts = '<div class="wp-post-navigation-next">'.$next_link.$prev_link.'</div>'; echo $posts; } } add_shortcode( 'custom_prev_next_link', 'prev_next_link' );Then use the following shortcode on a text element
[custom_prev_next_link]to display the next and prev button.Further customizations from here would be getting into custom development, which is outside the scope of support we can offer. If you need more in depth changes, you may wish to consult with a developer. X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding.
January 11, 2017 at 8:24 am #1325565
mateoserendipiaParticipantThank you very much, this was precisely what I was looking for, it works like a charm.
For other users stumbling upon this thread: the code above allows you to insert two links to previous and next posts anywhere in your page. This means however that you have to manually insert it in every page (or include it in a template). The words “volgend project” and “vorig project” mean “previous project” and “next project” respectively, and you can off course replace them with your own text. You can also change the icon (or delete it), change the alignment, and apply styling through css.
Thanks again!
January 11, 2017 at 9:37 am #1325678
JoaoModeratorThanks for your input 🙂
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1324127 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
