• Resolved lukemv

    (@lukemv)


    I have a PHP page that sits outside of the WordPress pages… (same directory as WP-Content). Within this PHP page, I wanted to list the blog posts whose tags include “XYZ”. Can anyone provide me the code that I can use to list these posts within this PHP code and link to them?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter lukemv

    (@lukemv)

    Does this matter that my blog isn’t in a subdirectory, but instead the pages are within what would be the sub directory’s folder? ie: in the same directory as the folder ‘wp-content’?

    Thread Starter lukemv

    (@lukemv)

    Using

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', false);
    require('./wp-blog-header.php');
    ?>

    Kills the page, without an error.

    why don’t you create a page template then use the query_posts() function to modify the loop to get the posts you want?

    Thread Starter lukemv

    (@lukemv)

    Because it is outside of the wordpress folder.

    the page template should be in the theme folder anyway.

    the fundamental question is why you’re creating a separate PHP page outside wordpress to pull data from the wordpress database, instead of just making use of features within the wordpress system to accomplish your task.

    Thread Starter lukemv

    (@lukemv)

    The primary reason is because I am using .htaccess (see code below) to rewrite the URL names for SEO…. the URLs are: URL.com/some_name_here_i123.html and it goes to URL.com/i.php, pulling the ID from $i and then dynamically populating the page from separate mySQL database.

    Previously, I had tried to have the same thing happen within a file in the WordPress theme directory, but it was having some conflicts the last time I tried and didn’t want to risk breaking it…

    Thoughts?

    HTACCESS

    <IfModule mod_rewrite.c>
    RewriteRule ^([^-]+)-([^&]+).html /i.php?id=$1&id=$2 [L]
    </IfModule>
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    but wordpress already does this automatically.

    URL.com/tags/tag-name

    Thread Starter lukemv

    (@lukemv)

    Obviously, but that is besides the point. I am not looking for a workaround to this. I am looking for making the code work outside of the theme folder—in the root folder for the WordPress theme.

    Thread Starter lukemv

    (@lukemv)

    Here is the correct code to do what I am trying to do:

    <?php require( 'path/to/wp-load.php' ); ?>

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Search Results, outside of WordPress’ is closed to new replies.