Plugin Development – Functions or Hooks?

Below I’ve included two hooks you could use. There may be better hooks depending on what you’re trying to accomplish exactly but this is what you’ve asked for. At the bottom I’ve listed some helpful resources: Publish Post Hook http://codex.wordpress.org/Plugin_API/Action_Reference/publish_post function published_post( $ID, $post ) { if( $post->post_type == ‘post’ ) { … } if( … Read more

Genesis – Adding custom hooks to display secondary navigation

Yes. you can do that. function my_custom_footer() { ?> <div class=”site-footer-logo”> <img src=”https://wordpress.stackexchange.com/questions/179519/<?=get_stylesheet_directory_uri();?>/images/my-logo-small.png” alt=”My Logo Small” /> </div> <?php do_action(‘my_own_hook’); ?> <p>Copyright &copy; <?=date(‘Y’);?>, my-url.com.</p> <?php } add_action( ‘my_own_hook’, ‘genesis_do_subnav’ ); function genesis_do_subnav(){ wp_nav_menu( array( ‘theme_location’ => ‘secondary-menu’ ) ); } You also can directly add: </div> <?php wp_nav_menu( array( ‘theme_location’ => ‘secondary-menu’ ) ); … Read more

Embeding style into the header via the function.php

You are not escaping your PHP correctly. In this part $output=”… <?php You could instead do it like this: add_action(‘wp_head’,’hook_css’); function hook_css() { ?> <!– Closing the PHP here –> <style> body { background-repeat: no-repeat; background-attachment: fixed; background-size: 100% 100%; background: url(‘../images/backgrounds/bg<?php echo rand(1,4); ?>.jpg’) no-repeat top center; } </style> <?php //Opening the PHP tag … Read more

Hook Adding content after title

Use in_the_loop() to know if you are currently in the loop of the main query. function after_title($title) { if ( in_the_loop() && ( is_single() || is_page() || is_home() || is_category() ) ) { $write=”AFTER TITLE”; $title = $title.$write; } return $title; } add_filter( ‘the_title’, ‘after_title’ );

Create a post builder skin in a plugin

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’, $this->skins … Read more

How do I hook into the container of wp_nav_menu?

Solved it by setting container to false and then wrapping it manually. <nav class=”main_navigation”> <div class=”topper”> <a href=”https://wordpress.stackexchange.com/questions/203496/<?=get_home_url()?>” class=”intranet”>H</a> </div> <?php wp_nav_menu(array(‘container’=>false) ?> </nav>