I have created a wordpress post. Used page break to break the page. Page numbers are working. But how can i add prev and next button insted of page number pagination??
Try this following code
<?php
$args = array(
'before' => '<p>' . __( 'Pages:' ),
'after' => '</p>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'next', //change into number for numeric pagination
'separator' => ' ',
'nextpagelink' => __( 'Next page' ),
'previouspagelink' => __( 'Previous page' ),
'pagelink' => '%',
'echo' => 1
);
wp_link_pages( $args );
?>
reference : https://codex.wordpress.org/Function_Reference/wp_link_pages
hope it helps
Related
I use the following code to show date input on the checkout page, after additional information:
add_action( 'woocommerce_after_order_notes', 'custom_checkout_field' );
function custom_checkout_field( $checkout ) {
echo '<div id="custom_checkout_field"><h2>' . __('Date picker:') . '</h2>';
woocommerce_form_field(
'custom_field_name', array(
'type' => 'date',
'class' => array( 'my-field-class form-row-wide' ),
'label' => __( 'Custom Additional Field' ),
'placeholder' => __( 'New Custom Field' ),
),
$checkout->get_value( 'custom_field_name' )
);
echo '</div>';
}
But there is a problem with this code, all days are selectable, I am looking for a way to make previous days, and Sundays unclickable. Please give me some tips to solve this problem.
I am making a blog site.
It has next button for every image using page break.
The next button is working in desktop perfectly but its not working in mobile.
$args = array(
'before' => '<center><p style="float:none;">' . __( '<span
style="margin-top:7px;font-size:18pt;">Page '.$page.'-
'.$numpages.'</span>' ),
'after' => '</p></center>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'next', //change into number for numeric
pagination
'separator' => ' ',
'nextpagelink' => __( '<button style="cursor:pointer;color:white;
background:#ff8000; border-
radius:40px;height:50px;width:250px;font-
size:15pt" class="btn"><span style>Next
</span><span class="dashicons dashicons-arrow-right-alt2"></span></button>' ),
'previouspagelink' => __(''),
'pagelink' => '%',
'echo' => 3
);
wp_link_pages( $args );
This works perfectly in desktop but does not respond in mobile
Try changning button to an anchor with the same styling, here's your updated code:
$args = array(
'before' => '<center><p style="float:none;">' . __( '<span
style="margin-top:7px;font-size:18pt;">Page '.$page.'-
'.$numpages.'</span>' ),
'after' => '</p></center>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'next', //change into number for numeric pagination
'separator' => ' ',
'nextpagelink' => __( '<span style="cursor:pointer;color:white;
background:#ff8000; border-
radius:40px;height:50px;width:250px;font-
size:15pt" class="btn">Next
</span><span class="dashicons dashicons-arrow-right-alt2"></span>' ),
'previouspagelink' => __(''),
'pagelink' => '%',
'echo' => 3
);
wp_link_pages( $args );
Good day, I am creating a plugin that will automatically posts a slideshow article with page break using <!--nextpage--> , my problem is i want to custom the pagination style instead of page: 1,2 i want to show up as next-page and previous-page. how can i achieved this one? i want to put the code inside the plugin i don't want to add codes in the theme.
I have already tried adding this code in my plugin but did not work:
$defaults = array(
'before' => '<h1>' . __( 'Pages:' ),
'after' => '</h1>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'next',
'separator' => ' ',
'nextpagelink' => __( 'Next page' ),
'previouspagelink' => __( 'Previous page' ),
'pagelink' => 'Page %',
'echo' => 1
);
wp_link_pages( $defaults );
This is the code in my plugin:
$x = "";
foreach ($leadamajig_data->questions as $post)
{
$lead_title = '<p><h1 id="title">' . $post->title . '</a></h1></p>';
$lead_choices = '<p><h1 id="clicked"><a hre="#">' . $post->choices->a . '</a></h1></p>';
$lead_choices2 ='<p><h1 id="clicked2"><a hre="#">' .$post->choices->b . '</a></h1></p>';
$lead_choices3 = '<p><h1 id="clicked3"><a hre="#">' . $post->choices->c . '</a></h1></p>';
$x = $x . $lead_title . $lead_choices . $lead_choices2 . $lead_choices3 . '<!--nextpage-->';
}
$my_post = array(
'post_title' => questions,
'post_content' => $x,
'post_status' => 'publish',
'post_author' => 1
);
wp_insert_post( $my_post );
wp_link_pages() returns the pagination markup you have defined with your $default array of parameters. So you probably already have the html that you want to show returned from the wp_link_pages() function.
Assign wp_link_pages() to a variable and then echo or print out the content where you want your pagination to appear.
Like this:
$defaults = array(
'before' => '<h1>' . __( 'Pages:' ),
'after' => '</h1>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'next',
'separator' => ' ',
'nextpagelink' => __( 'Next page' ),
'previouspagelink' => __( 'Previous page' ),
'pagelink' => 'Page %',
'echo' => 1
);
$pagination = wp_link_pages( $defaults );
//Put this where you want your pagination to appear:
echo $pagination;
add_filter( 'rwmb_meta_boxes', 'your_prefix_meta_boxes' );
function your_prefix_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array(
'title' => __( 'Custom theme 2 Metabox ', 'textdomain' ),
'post_types' => array('page'),
'fields' => array(
array(
'id' => 'htitle',
'name' => __( 'Home Page Title ', 'textdomain' ),
'type' => 'text',
),
array(
'id' => 'titlecss',
'name' => __( 'Title CSS', 'textdomain' ),
'type' => 'checkbox',
'desc' => __( 'CSS For "WELCOME TO"', 'your-prefix' ),
),
array(
'id' => 'titlecss2',
'name' => __( 'Title CSS2', 'textdomain' ),
'type' => 'checkbox',
'desc' => __( 'CSS For "Company name"', 'your-prefix' ),
),
),
);
return $meta_boxes;
}
help to get checkbox value i got value of text box like this
<?php echo rwmb_meta( 'htitle' ); ?>
but i m not able to fetch value of checkbox please help
<?php echo rwmb_meta( 'titlecss' ); ?
i got it by using id of checkbox
I'm attempting to register a new widget area in my Genesis child theme for WordPress. The code doesn't seem to be working and crashes my site. Can anyone tell me what I'm doing wrong here? I'm trying to get it above the content on all pages. This is the code I have:
genesis_register_sidebar( array(
'id' => ‘above_content’,
'name' => __( ‘Above Content’, 'domain' ),
'description' => __( ‘Above the content’, 'domain' ),
));
add_action( 'genesis_before_loop’, ‘above_content’ );
function your_widget() {
if ( is_active_sidebar(‘above_content’) ) {
genesis_widget_area( ‘above_content’, array(
'before' => '<div class=“above_content widget-area">',
'after' => '</div>',
));
}
}
Two things:
Make sure you're using standard quotes ', not curly quotes ‘
Assign the proper callback to your action
genesis_register_sidebar( array(
'id' => 'above_content',
'name' => __( 'Above Content', 'domain' ),
'description' => __( 'Above the content', 'domain' ),
) );
add_action( 'genesis_before_loop', 'your_widget' );
function your_widget() {
if ( is_active_sidebar('above_content') ) {
genesis_widget_area( 'above_content', array(
'before' => '<div class="above_content widget-area">',
'after' => '</div>',
) );
}
}
If you want to register another widget, just register a new sidebar (with a unique ID), and add new logic to a new callback function (or add it to your_widget()). Where you add this additional widget depends on your specific use case.