Tag Info

Hot answers tagged

5

You can use get_the_title() to return the current post title in the loop.


4

You can set the expire date as post meta value. In single.php you can easily show that date by querying the post meta. See update_post_meta() and get_post_meta() Now, the second part of your question is pretty tricky. I can think of 2 solutions. Cron You can use wordpress cron to run at a time interval to check which post has been expired and ...


3

What about using the WordPress function get_ancestors(), which Returns an array containing the parents of the given object. To be exact an Array of ancestors from lowest to highest in the hierarchy We can easily create a function to return a list by using implode to do so: function wpse185971_get_ancestors_list( $object_id, ...


2

$multipage is an "inside the Loop" variable. I did not track down exactly where and how it is set but given that information alone the obvious solution is to put your code inside a Loop, which is good practice anyway as a number of things depend upon that Loop. Something like: if (have_posts()) { while (have_posts() { the_post(); ...


2

It will be bit tricky to detect if user just get into site. But generally there will be no referer, hence wp_get_referer() will return false. My code check if there is referer, if no then they get redirected to post page. NOTE: When user access a page in admin by typying url in adressbar then redirect is applied to them also, because there are no ...


2

get_template_directory() returns a filesystem path-- that is, it returns the path to the file as it would appear if you were browsing it on the local machine via a file browser. Return Values (string) Absolute path to the directory of the current theme (without the trailing slash). ...


2

You have the following methods of the $wpdb object: $wpdb->flush() that contains a call to mysqli_free_result() or mysql_free_result() if not supported. $wpdb->check_connection() that contains a call to mysqli_ping() or mysql_ping() if not supported. You can of course use all your PHP functions in WordPress. Here's an example based on the \wpdb ...


1

jQuery is already loaded with WordPress, so you won't need <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> When using jQuery with WordPress, you'll likely require no-conflict wrappers : https://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers There are likely JS errors ...


1

The $multipage is constructed inside the setup_postdata() method of WP_Query. It's called when you run the_post(). So just as @s_ha_dum explained, you have to make a loop around it: You can try this: if( have_posts() ) { the_post(); // Make a call to setup_postdata(). echo sbwp_get_current_chapter(); // Display the current ...


1

If I had to guess, I'd say you're running into a memory leak like you suggested, infinite recursive loop. You need to run checks for when the term either hits the top of the ancestry tree or errors out: $ancestors = $terms[0]->term_id.GetAncestors( $terms[0]->term_id, $include ); function GetAncestors( $term_id, &$include ) { $child_term ...


1

Your snippet seems mostly ok, except that dependency is a list and should be array('jquery'). Also wp_enqueue_scripts should be use as more appropriate. You can check out Codex documentation for a complete example, see Example of Automatic Dependency Loading.


1

Use wp_register_script & wp_enqueue_script to enqueue the scripts the right way. add_action( 'wp_enqueue_scripts', 'enqueue_my_script' ); function enqueue_my_script() { wp_register_script( 'my-script', get_template_directory_uri() . '/cycle2.js', array( 'jquery' ) ); wp_register_script( 'enq-jquery', ...


1

I understand, that you add the possibilties for developers to change the html, typical a template part. That is the point, that I think you should use the default functionality for this job. get_page_template() can be overridden via the page_template filter. A simple example for the dev to change your templates from your plugin. add_filter( ...


1

You cannot insert the do_action() inside the class like that, it's gonna give you a fatal error. Instead you could use an array $skins to store all the skin functions (as closures), and the magic method _call() to call them: class skinclass { private $skins = array(); function __construct() { $this->skins = apply_filters( 'add_skin', ...


1

In your source you allow only the selector tag p for the class - 'selector' => 'p',. You find a longer answer with examples in this WPSE-Question. I think is not helpful to share the same content here in this question.


1

you can try a code like this <?php function theme_settings_init(){ register_setting( 'theme_settings', 'theme_settings' ); } ├« This is used to reserve a name for a custom settings array //Add settings to page menu function add_settings_page() { add_menu_page( __( 'Contenu ├ęditable' ), __( 'Contenu ├ęditable' ), 'manage_options', 'settings', ...



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