How to lock content?

You could hook into template_redirect, check if it is a singular page (post, page, custom post type) and force a log in: add_action( ‘template_redirect’, ‘login_to_see_content’ ); function login_to_see_content() { if ( is_singular() && ! is_user_logged_in() ) auth_redirect(); // does nothing for logged in users } As suggested by @s_ha_dum in the comments, an additional ! … Read more

Are all ID’s used unique?

If you look at the description for the different tables used by WordPress, the columns described as “auto_increment” will be unique. I am not sure what you are doing though. The URL structure you are using is not one that I recognize. That is, the syntax I think you want is this: example.com/?p=1774 rather than … Read more

Why can posts never have a number as the link?

Why Suffixes Are Appended to (Some) Numeric Post-Slugs WordPress posts can almost always have numeric permalinks, the exceptions being when they might conflict with another post, a feed, or a post post-type date archive, or are otherwise reserved. The wp_unique_post_slug() function mitigates these conflicts by appending a suffix. Potential date-archive conflicts arise when a numeric … Read more

adding a custom css class to post

Note – I recommend using the hook suggested by @Chip Bennett in another answer Here’s the modified version of that filter – function wpse_filter_post_class( $classes ) { $my_post_class = get_post_meta($post->ID, “your_meta_name”); if( $my_post_class != ” ) $classes[] = $my_post_class; return $classes; } add_filter( ‘post_class’, ‘wpse_filter_post_class’ ); You can setup a Custom fileds for that – … Read more

How can I edit a post from the frontend?

Just like the example you linked, but instead of using wp_insert_post() you use: wp_update_post() so your form becomes: <?php $post_to_edit = get_post($post_id); ?> <!– edit Post Form –> <div id=”postbox”> <form id=”new_post” name=”new_post” method=”post” action=””> <p> <label for=”title”>Title</label><br /> <input type=”text” id=”title” value=”<?php echo $post_to_edit->post_title; ?>” tabindex=”1″ size=”20″ name=”title” /> </p> <p> <label for=”description”>Description</label><br /> … Read more

Open WordPress Posts in Bootstrap Modal

This has been answered and this is how it was done: The grid and the modal window are in a loop. I simply added -<? the_ID(); ?> to bot the <a href> calling the modal window. and to the <div id> for the modal window which somehow passes the post ID to the window allowing … Read more

I am trying to create a simple frontend form for posting

To post from the front-end you can use wp_insert_post() function. So its simply a matter of a form and processing it the form: <!– New Post Form –> <div id=”postbox”> <form id=”new_post” name=”new_post” method=”post” action=””> <p><label for=”title”>Title</label><br /> <input type=”text” id=”title” value=”” tabindex=”1″ size=”20″ name=”title” /> </p> <p><label for=”description”>Description</label><br /> <textarea id=”description” tabindex=”3″ name=”description” cols=”50″ … Read more

Related posts display randomly by tag

Some of the code in OP is a bit old and depreciated, like caller_get_posts which was depreciated years ago. The correct parameter to use now is ignore_sticky_posts. Your query is also really inefficient and not good for performance. Here is how I would tackle this issue Use get_queried_object_id() to get the current post ID instead … Read more

Developing a secure front end posting form

Hopefully the code will be sufficient to describe the key points, but please do comment if you have any further questions: <?php class WPSE_Submit_From_Front { const NONCE_VALUE = ‘front_end_new_post’; const NONCE_FIELD = ‘fenp_nonce’; protected $pluginPath; protected $pluginUrl; protected $errors = array(); protected $data = array(); function __construct() { $this->pluginPath = plugin_dir_path( __file__ ); $this->pluginUrl = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)