Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Writing Wordpress Modules

  • 21-05-2015 1:35pm
    #1
    Registered Users, Registered Users 2 Posts: 1,987 ✭✭✭


    I'm looking for a good tutorial/examples on writing wordpress modules with custom PHP functionality, can anyone recommend any?
    Tagged:


Comments

  • Registered Users Posts: 1,533 ✭✭✭jooksavage


    Ziycon wrote: »
    I'm looking for a good tutorial/examples on writing wordpress modules with custom functionality, can anyone recommend any?

    This one got me started writing plugins
    http://www.elegantthemes.com/blog/tips-tricks/how-to-create-a-wordpress-plugin


  • Registered Users Posts: 1,533 ✭✭✭jooksavage


    Ziycon wrote: »
    I'm looking for a good tutorial/examples on writing wordpress modules with custom functionality, can anyone recommend any?

    Also if you want to add custom fields to all/specific site pages, the Advanced Custom Fields plugin will do almost everything you could want.


  • Registered Users, Registered Users 2 Posts: 1,987 ✭✭✭Ziycon


    It's to have a custom feature that will exist on one page that has some complex logic in it but only ever exists on the one page.


  • Registered Users Posts: 1,533 ✭✭✭jooksavage


    Ziycon wrote: »
    It's to have a custom feature that will exist on one page that has some complex logic in it but only ever exists on the one page.

    Is it going to have an admistrative screen in the Wordpress CMS, ie. Is it something that will be updated by logged-in users?


  • Registered Users, Registered Users 2 Posts: 1,987 ✭✭✭Ziycon


    jooksavage wrote: »
    Is it going to have an admistrative screen in the Wordpress CMS, ie. Is it something that will be updated by logged-in users?

    No, just pure functionality on the public facing page, no need for a backend admin section.


  • Advertisement
  • Registered Users Posts: 1,533 ✭✭✭jooksavage


    Probably don't need that plugin tutorial I posted earlier so.

    It might be just a case of a building something into your WordPress theme. Find the .php file you need to update (depends on the theme, could be header.php, content.php, content-page.php, etc.), locate where you want the functionality to appear and paste in the code inside conditional statement like if page(page id here){do stuff}


  • Registered Users, Registered Users 2 Posts: 1,987 ✭✭✭Ziycon


    I'd prefer it not to be part of the theme in case the theme changes hence the plugin route.


  • Registered Users, Registered Users 2 Posts: 6,528 ✭✭✭daymobrew


    For stuff like this I use shortcodes that I put where I want.

    You write a plugin and your shortcode function does what it needs to and returns a string of html that will appear in the page.
    The plugin is independent of the theme and is uploaded to the wp-content/plugins directory and activated in the Dashboard.

    As an example, here is a tiny plugin that I wrote for generating anchor and target links:
    [PHP]<?php
    /*
    Plugin Name: Anchor/Target shortcodes
    Plugin URI: http://www.damiencarbery.com
    Description: Shortcodes for generating anchor and target links.
    Author: Damien Carbery
    Version: 0.1

    $Id: anchor-target-shortcodes.php 2297 2014-01-01 21:53:29Z damien $
    */


    function ats_helper_shortcode($atts, $content, $code) {
    switch ($code) {
    // [anchor_link text='More Info' name='target']
    case 'anchor_link':
    extract(shortcode_atts(array(
    'name' => '',
    'text' => '',
    ), $atts));
    return '<a href="#'.$name.'">'.$text.'</a>';
    break;
    // [target_link name='target']
    case 'target_link':
    extract(shortcode_atts(array(
    'name' => '',
    ), $atts));
    return '<a id="'.$name.'"></a>';
    break;

    default:
    return '';
    }
    }

    add_shortcode('anchor_link', 'ats_helper_shortcode');
    add_shortcode('target_link', 'ats_helper_shortcode');
    ?>[/PHP]


  • Registered Users, Registered Users 2 Posts: 241 ✭✭fcrossen


    A plugin is the best way to do this.

    There are plenty of basic plugin tutorials (https://codex.wordpress.org/Writing_a_Plugin) but you should only need the most basic skeleton of a plugin, perhaps even a single file (like the "Hello Dolly" sample that ships with Wordpress). Look at the ""the_content" filter to change the page content.

    You will need to sniff out the current page from the wp_query object (make it global in your plugin file).


Advertisement