Use /prefix/postname as a slug in post_name?

Well it turns out you can’t use a slash (“https://wordpress.stackexchange.com/”) in the slug but I found a solution from How to set permalink structure via functions.php, set the permalink structure in your theme’s functions.php file add_action( ‘init’, function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure( ‘/episode/%postname%/’ ); } ); It will add /episode/ before the post slug

custom post for slider

Preblem is because inside loop you have UL echo ‘<ul>’; while ( $loop->have_posts() ) : $loop->the_post(); ?> <li data-transition=”fade” data-slotamount=”6″> <?php echo wp_get_attachment_image( get_post_thumbnail_id(), ‘full’, false, array( ‘class’ => ‘thumbnail zoom’ ) );?> <p><a href=”#.”><?php the_title();?></a></p> </li> <?php endwhile;echo ‘</ul>’; Just make one IF statment before echo-ing UL tag $loop = new WP_Query( $args ); … Read more

header_image() with CSS

No, in general, it’s not possible to use php in CSS. But you can set background image in php file. Like.. <div class=”headerimg” style=”background-image: url(<?php echo header_image(); ?>)”></div> Then in CSS file using class you can set all the other properties you need like height, width, background-position and so on.

Loop increase number

You can add a php variable and increment it every time the while loop runs $args = array( ‘post_type’ => ‘events’, ‘order’ => ‘ASC’, ); $wp_query = new WP_Query($args); ?> <script type=”application/ld+json”> { “@context”:”http://schema.org”, “@type”:”ItemList”, “itemListElement”:[ <?php $i=0; while ( have_posts() ) : the_post(); $i++; ?> { “@type”:”ListItem”, “position”:”<?php echo $i; ?>”, “url”:”<?php the_permalink(); ?>” … Read more

Can’t save php string to a custom field

For some reason, your $subject variable is empty when you call get_the_content($post_id). When using save_post hook, you can pass additional arguments like $post and $update to your callback. For your case, you could use the second argument $post to grab the post contents. Code: function save_url_link( $post_id, $post ){ $pattern = “/(http|https):\/\/.*\/(.*)\.(mp3|m4a|ogg|wav|wma)/”; $subject = $post->post_content; … Read more

How to check if a PHP string is different than meta field?

I suppose it deleted the value when you had no URL in the content, so $audio_raw was empty. if ($audio_raw && get_post_meta( $post_id, ‘audio_url’, true ) != $audio_raw) { // update the meta field update_post_meta( $post_id, ‘audio_url’, $audio_raw ); } checks that $audio_raw isn’t false/null/empty and that $audio_raw isn’t the same as the string currently … Read more

Custom Pagination is Broken

Chances are your pager is getting the count of all posts, regardless of whether they are published. In your query, you should add a filter for only published posts. $query_args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 4, ‘paged’ => $paged, ‘post_status’ = ‘publish’, ); Then the results count and number of pager links should … Read more