Hot answers tagged

4

Since you are already getting the ID of the newly created post ($post_id), you just need to get the URL and redirect after the submission. Using get_permalink( $post_id ) you can get post's URL. Also, you can get rid of the header() function to send a new HTTP header, and use WordPress' own function for redirect - wp_redirect(). wp_redirect( ...


4

You can use the_post hook to remove <!--nextpage-->. In this case: add_action( 'the_post', 'campaign_remove_nextpage', 99); function campaign_remove_nextpage ( $post ) { if ( ($_GET['utm_campaign']== 'nonextpagecampaign') && (false !== strpos( $post->post_content, '<!--nextpage-->' )) ) { // Reset the global $pages: ...


3

We can use the content_paginationcodex filter to modify the paginated content without modifying the globals directly: add_filter( 'content_pagination', function( $pages ) { // Target only the correct utm_campaign GET parameter if( 'nonextpagecampaign' !== filter_input( INPUT_GET, 'utm_campaign', FILTER_SANITIZE_STRING ) ) return $pages; ...


3

Why to edit the whole form ? Filters are good because they gives you the current output and you just need to add your string to it then return it back to WordPress. In above example you are not using it so let use it. Example:- add_filter('the_password_form', function( $form ){ $my_html = '<h2><br>Password Protected Area</h2>'; ...


3

Based on what you're asking and what I am understanding there is the_modified_date() or if you just want the value get_the_modified_date(). If you ever want the creation date you could use post_date and post_date_gmt. Several questions on this: How to get post creation date? What is considered the post's creation date for wp_insert_post? If you are ...


3

The correct method of doing this since Wordpress 4.4 is simply the following: add_filter( "get_next_post_where", function($where, $in_same_term, $excluded_terms, $taxonomy, $post){ $where .= " AND p.post_author='".$post->post_author."'"; return $where; }, 10, 5); add_filter( "get_previous_post_where", function($where, $in_same_term, $excluded_terms, ...


2

Newlines are not valid inside json strings. However you are outputting this code or otherwise checking it for sanity is somehow adding newlines into your long strings here. Check that your strings really are all one line and not broken up into multiple lines.


2

For a truly full solution you need to have all the users to have an account (or create one when marking as read) and you associate in the DB the user with the posts that he read and then style each link appropriately. To implement this you can look for inspiration in plugins that add a review or other like/ranking functionality. The problem with this ...


2

First check your template or source code to find the classes added to the article as a whole (or any html element that wraps around the whole post. It probably looks a bit like this: <article class="my-article"> <title class="my-title">TITLE</title> <img src="..." class="my-featured-image"/> <div class="my-content"> POST TEXT &...


2

the_permalink(), the_title() by default echo their value. As you want to store that value in a variable you will need to return the values instead. get_the_permalink(), get_the_title() are two similar functions that return the value instead of echo. So you new code may look something like this: $list = '<li class="ubermenu-submenu ubermenu-submenu-id-...


2

You can do something like this : // remove the script from the queue if were are on the post ID 11 add_action('wp_enqueue_scripts', 'remove_script_specific_post'); function remove_script_specific_post(){ if( 11==get_the_ID() ){ wp_dequeue_script('my_script_handle'); } } Provided that the script has been added with wp_enqueue_script


1

nopaging=true override posts_per_page and sets it to -1 which will return all posts. Remove that and you should be fine


1

Even though the recommendations have been updated to: To run WordPress we recommend your host supports: PHP version 5.6 or greater MySQL version 5.6 or greater OR MariaDB version 10.0 or greater the minimum requirements are not there yet: WordPress server requirements for Version 3.2+: PHP version 5.2.4 or greater MySQL ...


1

This has to work, Im using it in several projects: add_filter( 'excerpt_more', 'my_excerpt_more' ); function my_excerpt_more( $more ) { return ''; } Just copy-paste it to your functions.php. Little bonus snippet that you might need: add_filter( 'excerpt_length', 'my_excerpt_length' ); function my_excerpt_length( $length ) { return 50; } ...


1

If $size is already an array in your original code as it looks to be, then the argument passed will become array(array(150,150)) instead of just array(150,150) and fail, so you can just do: <?php $title=get_the_title(); the_post_thumbnail( $size, array( 'alt' =>$title) ); ?>


1

If you want to change the single page page-{page-slug} is a good choice if you want the page template for specific page only and not multiple pages. Check out his custom page template for specific page If you are talking about custom post type We can use single-$posttype.php , here $posttype is your custom post type slug. WordPress template Hierarchy ...


1

You need a custom query for that. Basically, just a query that pulls 1 result from the posts table where the post type is your custom post type: global $wpdb; // the name you gave to your custom post type $post_type = 'my_custom_post_type'; // this is the query string that we'll use with the $wpdb class // selecting from the posts table where the ...


1

I did this for a client and it looked like this: The PHP code: <dl class="tree-accordion"> <?php $currentyear = date("Y"); $years = range($currentyear, 1950); foreach($years as $year) { ?> <dt><a href=""><i class="fa fa-fw fa-plus-square-o" aria-hidden="true"></i> <?php echo $year; ?></a&...



Only top voted, non community-wiki answers of a minimum length are eligible