Skip to content

Instantly share code, notes, and snippets.

@JacquesvanWyk
Last active April 19, 2018 08:53
Show Gist options
  • Select an option

  • Save JacquesvanWyk/26463d0e5b18cf18b10372f090bd7f0f to your computer and use it in GitHub Desktop.

Select an option

Save JacquesvanWyk/26463d0e5b18cf18b10372f090bd7f0f to your computer and use it in GitHub Desktop.

Revisions

  1. JacquesvanWyk revised this gist Apr 19, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ I assume here you know how to get the button up and running if you dont please j

    We need to just make function calling the correct url when clicking share so go to your functions.php file and add this code:

    `function myblog_post_by_slug($the_slug, $post_type = "page"){
    > `function myblog_post_by_slug($the_slug, $post_type = "page"){
    $args = array(
    'name' => $the_slug,
    'post_type' => $post_type,
  2. JacquesvanWyk revised this gist Apr 19, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ I assume here you know how to get the button up and running if you dont please j

    We need to just make function calling the correct url when clicking share so go to your functions.php file and add this code:

    function myblog_post_by_slug($the_slug, $post_type = "page"){
    `function myblog_post_by_slug($the_slug, $post_type = "page"){
    $args = array(
    'name' => $the_slug,
    'post_type' => $post_type,
    @@ -20,7 +20,7 @@ function myblog_post_by_slug($the_slug, $post_type = "page"){
    );
    $my_page = get_posts($args)[0];
    return $my_page;
    }
    }`

    This function will help get the slug of your current post now all you need to do is change the data-href(you get this in step 3 on facbebook developers) to this:

  3. JacquesvanWyk revised this gist Apr 19, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ function myblog_post_by_slug($the_slug, $post_type = "page"){

    This function will help get the slug of your current post now all you need to do is change the data-href(you get this in step 3 on facbebook developers) to this:

    > data-href="<?php echo myblog_post_by_slug('map'); ?>"
    > `data-href="<?php echo myblog_post_by_slug('map'); ?>"`


  4. JacquesvanWyk revised this gist Apr 19, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -24,11 +24,11 @@ function myblog_post_by_slug($the_slug, $post_type = "page"){

    This function will help get the slug of your current post now all you need to do is change the data-href(you get this in step 3 on facbebook developers) to this:

    data-href=""
    > data-href="<?php echo myblog_post_by_slug('map'); ?>"


    inside double quotes add this

    <?php echo myblog_post_by_slug('map'); ?>

    ## Hope this helped if you got problems leave comment

  5. JacquesvanWyk revised this gist Apr 19, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -24,8 +24,11 @@ function myblog_post_by_slug($the_slug, $post_type = "page"){

    This function will help get the slug of your current post now all you need to do is change the data-href(you get this in step 3 on facbebook developers) to this:

    data-href="<?php echo myblog_post_by_slug('map'); ?>"
    data-href=""

    inside double quotes add this

    <?php echo myblog_post_by_slug('map'); ?>

    ## Hope this helped if you got problems leave comment

  6. JacquesvanWyk revised this gist Apr 19, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ function myblog_post_by_slug($the_slug, $post_type = "page"){

    This function will help get the slug of your current post now all you need to do is change the data-href(you get this in step 3 on facbebook developers) to this:

    // data-href="<?php echo myblog_post_by_slug('map'); ?>"
    data-href="<?php echo myblog_post_by_slug('map'); ?>"


    ## Hope this helped if you got problems leave comment
  7. JacquesvanWyk revised this gist Apr 19, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ function myblog_post_by_slug($the_slug, $post_type = "page"){

    This function will help get the slug of your current post now all you need to do is change the data-href(you get this in step 3 on facbebook developers) to this:

    data-href="<?php echo myblog_post_by_slug('map'); ?>"
    // data-href="<?php echo myblog_post_by_slug('map'); ?>"


    ## Hope this helped if you got problems leave comment
  8. JacquesvanWyk revised this gist Apr 19, 2018. 1 changed file with 18 additions and 74 deletions.
    92 changes: 18 additions & 74 deletions Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -1,88 +1,32 @@
    # Project Title
    # Share you Wordpress post with facebook using correct post url

    One Paragraph of project description goes here
    If you struggle to get the correct url for your share button here is a fix.

    ## Getting Started

    These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
    I assume here you know how to get the button up and running if you dont please just go to https://developers.facebook.com/docs/plugins/share-button and follow instructions

    ### Prerequisites

    What things you need to install the software and how to install them
    ### Code to get the correct url shared

    ```
    Give examples
    ```
    We need to just make function calling the correct url when clicking share so go to your functions.php file and add this code:

    ### Installing
    function myblog_post_by_slug($the_slug, $post_type = "page"){
    $args = array(
    'name' => $the_slug,
    'post_type' => $post_type,
    'post_status' => 'publish',
    'numberposts' => 1
    );
    $my_page = get_posts($args)[0];
    return $my_page;
    }

    A step by step series of examples that tell you have to get a development env running
    This function will help get the slug of your current post now all you need to do is change the data-href(you get this in step 3 on facbebook developers) to this:

    Say what the step will be
    data-href="<?php echo myblog_post_by_slug('map'); ?>"

    ```
    Give the example
    ```

    And repeat
    ## Hope this helped if you got problems leave comment

    ```
    until finished
    ```

    End with an example of getting some data out of the system or using it for a little demo

    ## Running the tests

    Explain how to run the automated tests for this system

    ### Break down into end to end tests

    Explain what these tests test and why

    ```
    Give an example
    ```

    ### And coding style tests

    Explain what these tests test and why

    ```
    Give an example
    ```

    ## Deployment

    Add additional notes about how to deploy this on a live system

    ## Built With

    * [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used
    * [Maven](https://maven.apache.org/) - Dependency Management
    * [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds

    ## Contributing

    Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.

    ## Versioning

    We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).

    ## Authors

    * **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth)

    See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.

    ## License

    This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

    ## Acknowledgments

    * Hat tip to anyone who's code was used
    * Inspiration
    * etc

  9. JacquesvanWyk revised this gist Apr 19, 2018. 1 changed file with 88 additions and 10 deletions.
    98 changes: 88 additions & 10 deletions Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,88 @@
    function jvw_post_by_slug($the_slug, $post_type = "page"){
    $args = array(
    'name' => $the_slug,
    'post_type' => $post_type,
    'post_status' => 'publish',
    'numberposts' => 1
    );
    $my_page = get_posts($args)[0];
    return $my_page;
    }
    # Project Title

    One Paragraph of project description goes here

    ## Getting Started

    These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

    ### Prerequisites

    What things you need to install the software and how to install them

    ```
    Give examples
    ```

    ### Installing

    A step by step series of examples that tell you have to get a development env running

    Say what the step will be

    ```
    Give the example
    ```

    And repeat

    ```
    until finished
    ```

    End with an example of getting some data out of the system or using it for a little demo

    ## Running the tests

    Explain how to run the automated tests for this system

    ### Break down into end to end tests

    Explain what these tests test and why

    ```
    Give an example
    ```

    ### And coding style tests

    Explain what these tests test and why

    ```
    Give an example
    ```

    ## Deployment

    Add additional notes about how to deploy this on a live system

    ## Built With

    * [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used
    * [Maven](https://maven.apache.org/) - Dependency Management
    * [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds

    ## Contributing

    Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.

    ## Versioning

    We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).

    ## Authors

    * **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth)

    See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.

    ## License

    This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

    ## Acknowledgments

    * Hat tip to anyone who's code was used
    * Inspiration
    * etc

  10. JacquesvanWyk created this gist Apr 19, 2018.
    10 changes: 10 additions & 0 deletions Wordpress share post url with facebook.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    function jvw_post_by_slug($the_slug, $post_type = "page"){
    $args = array(
    'name' => $the_slug,
    'post_type' => $post_type,
    'post_status' => 'publish',
    'numberposts' => 1
    );
    $my_page = get_posts($args)[0];
    return $my_page;
    }