Link for the page archive for posts, like using custom post types with get_post_type_archive_link

I use a shortcode: function shortcode_article_list() { $posts_array = get_posts( array(‘posts_per_page’ => -1, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’) ); $output=”<ul>”; foreach ($posts_array as $post) { $a = explode(‘ ‘, $post->post_date); $output .= ‘<li><a href=”‘ . home_url(“https://wordpress.stackexchange.com/”) . $post->post_name . ‘.html”>’ . $post->post_title . ‘</a> (‘ . $a[0] . … Read more

Working Bootstrap Carousel Conversion to WP – Technical Questions

I had a similar situation recently, making a Bootstrap carousel dynamic. Here’s my functions.php code for that: //Images Slider function themename_slider_home_images_setup($wp_customize) { $wp_customize->add_section(‘home-slider-images’, array( ‘title’ => ‘Home Slider’, )); $wp_customize->add_setting(‘home-slider-first-image’); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, ‘home-slider-first-image’, array( ‘label’ => __( ‘First Image’, ‘theme_name’ ), ‘section’ => ‘home-slider-images’, ‘settings’ => ‘home-slider-first-image’ ) ) ); $wp_customize->add_setting(‘home-slider-second-image’); $wp_customize->add_control( new … Read more

WordPress won’t save any post

Following advices from other contributors I’m posting here the “solution” for future reference, just in case someone is experiencing the same issues. As I wrote in one of the comments, while investigating the REST API problem – by the way, I’d have never narrowed it down without some help from @SallyCJ – I found out … Read more

Alternate custom content in the loop

You could initialize a second counter variable that increments when your first counter variable increments, and use that with modulus to alternate your code blocks. First initialize two counter variables: <?php if (have_posts()) : $show_alternate = 1; $which_alternate = 1; while (have_posts()) : the_post(); ?> Then in your .pin-alternate-content output code you could do something … Read more

POST from jQuery to PHP

When you load your process.php file directly, it’s not within the context of the WordPress environment, so no WordPress functions are available. WordPress has a native AJAX API that should be used for this sort of thing. First, enqueue your javascript file, then use wp_localize_script to pass the location of admin-ajax.php, which will be processing … Read more

How to get new post URL?

admin_url(‘post-new.php’); The admin_url function will handle generating most of the link, you just need to give it the final component. You can pass in GET parameters as well. Just look at the backend URL to see what you need. admin_url(‘post-new.php?post_type=page’); Or using add_query_arg as suggested by @Rarst … add_query_arg(array(‘post_type’=>’page’),admin_url(‘post-new.php’)); It is overkill for simple URLs … Read more